Convert wide chars lazarus / 31-LCL ---------------------------------------------------------------------- arneolav · 2015-01-23 23:08 Got this string from an API service,  json and xml: JSON "name":"\u00c5\u00d8\u00c6 \u00e5\u00f8\u00e6" XML  name="ÅØÆ åøæ" I'm trying to convert these strings to Utf8 and/or Ansi, but cat get any conversion to work. Have been reading all I can find of Lazarus/utf converting, got no idea. From server: Server: Apache/2.2.22 (Debian) X-Powered-By: PHP/5.4.4-14+deb7u8 Lazarus 1.2.6 r46529 FPC 2.6.4 i386-win32-win32/win64 ---------------------------------------------------------------------- skalogryz · 2015-01-24 02:50 if you're parsing the string with FPC jsonscanner, then it should convert these wide chars to utf8 for you. However, the result of conversion doesn't make much sense, unless this is some sort of encryption API? or some unicoded ansi-coding Which might occur, if previously pushed data was wrong... or the server is misconfigured. The result looks like this: ÅØÆ åøæ Is it like upper/lower case test? any specific reason why there's 32-byte difference between the first and the second set of characters? ---------------------------------------------------------------------- arneolav · 2015-01-24 08:50 Thanks, Sorry I did't write, Yes it is a test of the chars: ÅØÆ åøæ, . There is no encryption, execpt the communication is https:/... and transport Synapse trunk version (oAuth) As XML I can recive a text like this: name="Hjemme Nedbør" The char "ø" should be converten to "ø". To solve this I know I can make a table, my own convert, but I think something exists. Not reinvent the wheel... ---------------------------------------------------------------------- arneolav · 2015-01-24 10:11 Seems to be solved by: Removed lazutf8 replaced by:  uses ... lazutils ---------------------------------------------------------------------- marcov · 2015-01-24 15:51 Code: [Select] uses cwstring; const xx = #$00C5#$00D8#$00C6#$00E5#$00E6;  // UCS codepoints. var s : utf8string;     a : ansistring;    s2:unicodestring; begin  a:=xx;  writeln(a);  s:=xx;  writeln(s);  s2:=xx;  writeln(s2); end. Prints (FreeBSD, utf8 console, FPC 3.1.1): Code: [Select]ÅØÆåæ à ÃÃåæ ÅØÆåæ with "uses cwstring" Code: [Select]ÅØÆåæ AOAEaae AOAEaae with "uses fpwidestring" Code: [Select]ÅØÆåæ ÅØÆåæ ÅØÆåæ The various right and wrongs probably depend on proper initialization of the current codepage by whatever unicode conversion driver unit. (cwstring, fpwidestring)