Recent

Author Topic: Why pchar can not show Chinese characters properly  (Read 2389 times)

badmintonfan

  • New Member
  • *
  • Posts: 49
Why pchar can not show Chinese characters properly
« on: June 07, 2018, 05:39:23 am »
I try to pchar a string with Chinese characters
 MessageBox(0,PChar(UTF8ToAnsi('正常显示中文')),PChar(UTF8ToAnsi('提示')),MB_OK or MB_ICONEXCLAMATION);
but can not show properly,picture is attached
is there anyone know the solution!

ASerge

  • Hero Member
  • *****
  • Posts: 2481
Re: Why pchar can not show Chinese characters properly
« Reply #1 on: June 07, 2018, 05:59:08 am »
Code: Pascal  [Select][+][-]
  1.   MessageBoxW(0, PWideChar(UTF8Decode('正常显示中文')), PWideChar(UTF8Decode('提示')),  MB_OK or MB_ICONEXCLAMATION);

wp

  • Hero Member
  • *****
  • Posts: 13485
Re: Why pchar can not show Chinese characters properly
« Reply #2 on: June 07, 2018, 11:34:47 am »
Or use MessageDlg:
Code: Pascal  [Select][+][-]
  1.   MessageDlg('提示', '正常显示中文', mtWarning, [mbOK], 0);

Even your PChar version is working for me with Laz trunk/fpc 3.0.4 (new strings)  and with Laz 1.4.4/fpc 2.6.4 (old strings) if you don't call UTF8ToAnsi, i.e.
Code: Pascal  [Select][+][-]
  1.    MessageBox(0,PChar('正常显示中文'),PChar('提示'),MB_OK or MB_ICONEXCLAMATION);

badmintonfan

  • New Member
  • *
  • Posts: 49
[Solved]Why pchar can not show Chinese characters properly
« Reply #3 on: June 08, 2018, 09:54:30 am »
Perfect, thanks everyone!

 

TinyPortal © 2005-2018