Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

59 wiersze
1.8 KiB

  1. unit utsContext;
  2. {$IFDEF FPC}
  3. {$mode objfpc}{$H+}
  4. {$ENDIF}
  5. interface
  6. uses
  7. Classes, SysUtils,
  8. utsUtils, utsTypes;
  9. type
  10. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  11. TtsContext = class(TtsRefManager)
  12. private
  13. fCodePage: TtsCodePage;
  14. fDefaultChar: WideChar;
  15. public
  16. property CodePage: TtsCodePage read fCodePage write fCodePage;
  17. property DefaultChar: WideChar read fDefaultChar write fDefaultChar;
  18. function AnsiToWide(const aText: PAnsiChar): PWideChar; overload;
  19. function AnsiToWide(const aText: PAnsiChar; const aLength: Integer): PWideChar; overload;
  20. constructor Create;
  21. end;
  22. implementation
  23. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  24. //TtsContext////////////////////////////////////////////////////////////////////////////////////////////////////////////
  25. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  26. function TtsContext.AnsiToWide(const aText: PAnsiChar): PWideChar;
  27. begin
  28. result := AnsiToWide(aText, Length(aText));
  29. end;
  30. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  31. function TtsContext.AnsiToWide(const aText: PAnsiChar; const aLength: Integer): PWideChar;
  32. begin
  33. result := nil;
  34. if not Assigned(aText) then
  35. exit;
  36. result := tsStrAlloc(aLength);
  37. tsAnsiToWide(result, aLength, aText, fCodePage, fDefaultChar);
  38. end;
  39. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  40. constructor TtsContext.Create;
  41. begin
  42. inherited Create(nil);
  43. fCodePage := tsUTF8;
  44. fDefaultChar := '?';
  45. end;
  46. end.