Author Topic: Add-on "Tags" and UTF8  (Read 350 times)

Somepony

  • Posts: 7
Add-on "Tags" and UTF8
« on: 19 May '19 - 04:08 »
Hey.

From the module:
Code: [Select]
function TAGS_SetUTF8(enable: BOOL): BOOL; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF}; external tagsdll;
function TAGS_Read(handle: DWORD; const fmt: PAnsiChar): PAnsiChar; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF}; external tagsdll;

Whats the point of SetUTF8 function, if Read returns AnsiChar? There is no WideChar version.
If i call TAGS_SetUTF8(True), then for example char "" returns as 2 chars "Г". Otherwise "" returns as "a".
« Last Edit: 19 May '19 - 04:15 by Somepony »

Falcosoft

  • Posts: 38
Re: Add-on "Tags" and UTF8
« Reply #1 on: 19 May '19 - 17:27 »
Hi,
Even in modern Delphi UTF8 is handled as single byte string since in case of UTF8 encoding the smallest meaningful units (ASCII characters) are single byte. So in case of UTF8  a 2-byte widechar version would not work.

You can find in modern Delphi:
Code: [Select]
UTF8String = type AnsiString(65001);
UTF8 is also handled as single byte in Lazarus/Freepascal:
Code: [Select]
UTF8String = type AnsiString(CP_UTF8);

Somepony

  • Posts: 7
Re: Add-on "Tags" and UTF8
« Reply #2 on: 20 May '19 - 01:13 »
Ok. How does this help me get UTF8 chars in tags in correct form?

Ian @ un4seen

  • Administrator
  • Posts: 21979
Re: Add-on "Tags" and UTF8
« Reply #3 on: 20 May '19 - 12:52 »
I'm not a Delphi user myself, but the UTF8ToString function looks like what you want:

   http://docwiki.embarcadero.com/Libraries/Rio/en/System.UTF8ToString

Somepony

  • Posts: 7
Re: Add-on "Tags" and UTF8
« Reply #4 on: 20 May '19 - 13:44 »
Thanks! This function helped me.