Recent

Author Topic: Passing Unicode filenames to TUTF8Process  (Read 21413 times)

mdalacu

  • Full Member
  • ***
  • Posts: 233
    • dmSimpleApps
Re: Passing Unicode filenames to TUTF8Process
« Reply #15 on: December 04, 2015, 08:52:53 am »
Avoid string problem,

use "pchar(utf8encode(<unicodestring>))" is good way in fpc >= 2.7

RTL string function always assume dest encoding is "defaultsystemcodepage",
it make trouble sometimes.
Yes, but TProcess.CommandLine is String.... how can i do it?

balazsszekely

  • Guest
Re: Passing Unicode filenames to TUTF8Process
« Reply #16 on: December 04, 2015, 11:20:59 am »
Quote
@mdalacu
Yes, but TProcess.CommandLine is String.... how can i do it?
CommandLine is deprecated. Since you need widestring, you're probably under windows. TProcess can be easily replaced with Createprocess, ShellExecute, ShellExecuteEx, etc..., or you can override a few methods in TProcess to accept widestrings, even better you only need to override the execute method with ExecuteUnicode.
Inside ExecuteUnicode convert all strings to widestring and instead PChar use PWideChar:
Code: Pascal  [Select][+][-]
  1. uses LazUTF8;
  2. var
  3.   FCommandLineW: WideString;
  4. begin
  5.    FCommandLineW := UTF8ToUTF16(FCommandLine);
  6.   //and so on
  7. end;
  8.  
  9.  
« Last Edit: December 04, 2015, 11:24:05 am by GetMem »

 

TinyPortal © 2005-2018