Recent

Author Topic: Need Help for UNICODE UTF-8 Support... Please...  (Read 8290 times)

Takeda

  • Full Member
  • ***
  • Posts: 157
Need Help for UNICODE UTF-8 Support... Please...
« on: July 17, 2011, 12:50:52 pm »
Day by day I saw, it would be the good things if my app is support UTF-8.
But more than a half months I waste my times and I got nothing.. So so sad..

I created an application to call another Executable (EXE) by Passing the parameter via TProcessUTF8 CommandLine..

My code snippets :

Code: [Select]
........

var
  AProcess: TProcessUTF8;
 
// starts to run
begin

  AProcess := TProcessUTF8.Create(nil);
 
  //mSentCommand is UTF8String Data Type, this is contain the Command and Another Exe. This var is 
 //created to catch my Command to call another EXE
  AProcess.CommandLine := mSentCommand;
 
 
  AProcess.Options := [poWaitOnExit, poNoConsole, poUsePipes];;
 

  AProcess.Execute;

   if ExitStatus <> 0 then
    begin
          with TStringList.Create do
            try
              LoadFromStream(StdErr);
              Msg := Text;
            finally
              Free;
            end;

          iMsg := 'Failed ! ';
     end
   else iMsg := 'Completed Successfully';
 
  AProcess.Free;   
end.

.......

The EXE that I called via TProcessUTF8, is give the result 'Failed - [FilePath+FileName] is not available'.

Note :
1. I tested to passing the command via CommandLine, with this combination Korean Character + Normal Character.
2. I tested to create the folder with Korean & Vietnamese character  and then give the same Error.
3. I use normal Windows (But I already install the suggestion from http://wiki.lazarus.freepascal.org/LCL_Unicode_Support)


I hope anyone in here will help me..

Regards,
Takeda.
Call me Takeda coz that's my true name.
Pascal coding using Lazarus => "Be native in any where.."

ƪ(˘⌣˘)┐ ƪ(˘⌣˘)ʃ ┌(˘⌣˘)ʃ

lainz

  • Guest
Re: Need Help for UNICODE UTF-8 Support... Please...
« Reply #1 on: July 21, 2011, 01:09:57 am »
Hi, i'm not an expert but if you're using Windows try using ShellExecuteW

For example:

This run an executable in a folder placed in a subfolder where you are running your exe:

Quote

RunExe('someprogram.exe','-?','somefolder');

procedure RunExe(ExeName, Parameters, Folder: String);
begin
  ShellExecuteW(
  0,
  'open',
  PWideChar(UTF8ToUTF16(ExtractFilePath(ParamStrUTF8(0)) + Folder + pathdelim + ExeName)),
  PWideChar(UTF8ToUTF16(Parameters)),
  PWideChar(UTF8ToUTF16(ExtractFilePath(ParamStrUTF8(0)) + Folder)),
  SW_SHOWDEFAULT);
end;

But i don't know how to read the output.

About this thread:

http://www.lazarus.freepascal.org/index.php/topic,13885.0.html

In the msdn says that WinExec is older and you must use CreateProcess function, or in your case CreateProcessW

http://msdn.microsoft.com/en-us/library/ms682425(v=vs.85).aspx
« Last Edit: July 21, 2011, 01:12:03 am by lainz »

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Need Help for UNICODE UTF-8 Support... Please...
« Reply #2 on: July 21, 2011, 07:30:55 am »
How do you build mSentCommand ? You need to post more code, only this part is not enough.

In general you need to remember that the FCL RTL uses Ansi strings, which are not unicode, and the LCL uses UTF-8, so the LCL fully supports Unicode. I am not saying that this is the problem in this case, because there is not enough code to say it for sure.

Lazarus already provides almost everything you could need for Unicode support, however, so it is not a problem to build fully unicode programs with Lazarus. The LCL duplicates some parts of the RTL in order to get unicode support, just like processutf8 does.

Takeda

  • Full Member
  • ***
  • Posts: 157
Re: Need Help for UNICODE UTF-8 Support... Please...
« Reply #3 on: July 21, 2011, 11:43:06 am »
Hi, i'm not an expert but if you're using Windows try using ShellExecuteW

For example:

This run an executable in a folder placed in a subfolder where you are running your exe:

Quote

RunExe('someprogram.exe','-?','somefolder');

procedure RunExe(ExeName, Parameters, Folder: String);
begin
  ShellExecuteW(
  0,
  'open',
  PWideChar(UTF8ToUTF16(ExtractFilePath(ParamStrUTF8(0)) + Folder + pathdelim + ExeName)),
  PWideChar(UTF8ToUTF16(Parameters)),
  PWideChar(UTF8ToUTF16(ExtractFilePath(ParamStrUTF8(0)) + Folder)),
  SW_SHOWDEFAULT);
end;

But i don't know how to read the output.

About this thread:

http://www.lazarus.freepascal.org/index.php/topic,13885.0.html

In the msdn says that WinExec is older and you must use CreateProcess function, or in your case CreateProcessW

http://msdn.microsoft.com/en-us/library/ms682425(v=vs.85).aspx

Ok, I'll try to use it..
Thank you very much, Sir..
Call me Takeda coz that's my true name.
Pascal coding using Lazarus => "Be native in any where.."

ƪ(˘⌣˘)┐ ƪ(˘⌣˘)ʃ ┌(˘⌣˘)ʃ

Takeda

  • Full Member
  • ***
  • Posts: 157
Re: Need Help for UNICODE UTF-8 Support... Please...
« Reply #4 on: July 21, 2011, 11:56:13 am »
How do you build mSentCommand ? You need to post more code, only this part is not enough.

In general you need to remember that the FCL RTL uses Ansi strings, which are not unicode, and the LCL uses UTF-8, so the LCL fully supports Unicode. I am not saying that this is the problem in this case, because there is not enough code to say it for sure.

Lazarus already provides almost everything you could need for Unicode support, however, so it is not a problem to build fully unicode programs with Lazarus. The LCL duplicates some parts of the RTL in order to get unicode support, just like processutf8 does.

mSentCommand is contain like this => "Exe2" + "Parameter" + "PathFileTargetToCallByExe2" + "Parameter
NOTE : mSentCommand is UTF8String (In my test cases PathFileTargetToCallbyExe2 is contain File/folder with Korean/Vietnamese Language). Everything look fine when mSentCommand only contain "Normal Character" not "Special Character" like Korean/Vietnamese. :(

Yes, I know, LCL Fully Unicode..
That's why It's working properly in GUI Level to show Unicode Character.. But When I pass the mSentCommand to AProcess.CommandLine it was fail to find the file in the folder with Korean/Vietnamese Language..
« Last Edit: July 21, 2011, 11:58:58 am by Takeda »
Call me Takeda coz that's my true name.
Pascal coding using Lazarus => "Be native in any where.."

ƪ(˘⌣˘)┐ ƪ(˘⌣˘)ʃ ┌(˘⌣˘)ʃ

 

TinyPortal © 2005-2018