Recent

Author Topic: how can I to do?? unicode strings....  (Read 6415 times)

wylton

  • Jr. Member
  • **
  • Posts: 50
how can I to do?? unicode strings....
« on: August 17, 2013, 08:14:17 pm »
procedure TForm1.Button6Click(Sender: TObject);
begin
  showmessage(systoutf8(utf8tosys('中文测试, ñiña, 这是世界, fuck')));
end;


typo

  • Hero Member
  • *****
  • Posts: 3051
Re: how can I to do?? unicode strings....
« Reply #1 on: August 17, 2013, 09:33:02 pm »
Code: [Select]
showmessage('中文测试, ñiña, 这是世界, fuck');
At least on my system (Brazilian Win 32) I can see the chinese characters.

wylton

  • Jr. Member
  • **
  • Posts: 50
Re: how can I to do?? unicode strings....
« Reply #2 on: August 17, 2013, 10:22:29 pm »
are you saw the png picture?

it can't show "ñiña"!!

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: how can I to do?? unicode strings....
« Reply #3 on: August 17, 2013, 10:50:49 pm »
You may need to install some european language set on your operating system (go in language settings of Windows). I don't have chinese installed so i don't see those chinese characters. I can see the ñiña however.
« Last Edit: August 22, 2013, 03:44:18 am by User137 »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: how can I to do?? unicode strings....
« Reply #4 on: August 17, 2013, 11:02:26 pm »
Don't use utf8tosys, instead use utf8decode/encode. If I remember correctly utf8tosys will convert to ansi not unicode and usually ANSI does not support more than 2 languages (English and your local language).
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Bart

  • Hero Member
  • *****
  • Posts: 5702
    • Bart en Mariska's Webstek
Re: how can I to do?? unicode strings....
« Reply #5 on: August 17, 2013, 11:29:41 pm »
SysToUtf8 and Utf8ToSys use current Windows codepage.
Any character that is not inside the current codepage gets lost in translation.

Bart

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: how can I to do?? unicode strings....
« Reply #6 on: August 18, 2013, 12:07:25 am »
are you saw the png picture?

it can't show "ñiña"!!

I can see here all the characters shown by the picture. And I can see ñiña.
« Last Edit: August 18, 2013, 12:10:15 am by typo »

bylaardt

  • Sr. Member
  • ****
  • Posts: 310
Re: how can I to do?? unicode strings....
« Reply #7 on: August 18, 2013, 08:30:26 pm »
I  encode it just  so:

Code: [Select]
showmessage('中文测试, ñiña, 这是世界, fuck');

But i save my source file  with UTF8 properties.

Open the source file with an text editor (I use the "kate" in KDE. If you use windows, you can use the notepad.exe) and save as UTF8.

Here works!

wylton

  • Jr. Member
  • **
  • Posts: 50
Re: how can I to do?? unicode strings....
« Reply #8 on: August 19, 2013, 06:32:29 pm »
i want to write/read to/from registry of windows, if use utf8decode/encode, i see not correct in registry..

bylaardt

  • Sr. Member
  • ****
  • Posts: 310
Re: how can I to do?? unicode strings....
« Reply #9 on: August 20, 2013, 05:52:52 am »
can you write/read in UTF8 in the win registry?
 I have no windows here to test it!

put a UTF8 sentence in a data registry with the regedit, reload the registry (i notsure if is reset need), and say me if the sentence is the same.

can you test it?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12706
  • FPC developer.
Re: how can I to do?? unicode strings....
« Reply #10 on: August 20, 2013, 10:42:32 am »
can you write/read in UTF8 in the win registry?

No. Windows usually provides two interfaces, one ansi (current codepage) and one UTF16.  But the current registry unit only supports ansi.

You can of course stuff utf8 in any byte array, but that is something else then the registry understanding the encoding.

bylaardt

  • Sr. Member
  • ****
  • Posts: 310
Re: how can I to do?? unicode strings....
« Reply #11 on: August 21, 2013, 11:54:40 pm »
thanks marcov,

sorry wilton but you'll use encode/decode or a array even when is not directly readable in the registry.

 

TinyPortal © 2005-2018