What is the "correct" way to convert PAnsiChar to a unicode string? Get link Facebook X Pinterest Email Other Apps - January 09, 2015 What is the "correct" way to convert PAnsiChar to a unicode string?http://stackoverflow.com/q/27857479/49925 Get link Facebook X Pinterest Email Other Apps Comments Lars FosdalJanuary 9, 2015 at 4:40 AMBack in the pre-Unicode days, it was MultiByteToWideChar/WideCharToMultiByte that was the go-to tools for code page and character set conversion. http://msdn.microsoft.com/en-us/library/windows/desktop/dd319072(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/windows/desktop/dd374130(v=vs.85).aspx Both require you to know the CP of the source/target.More info: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317752(v=vs.85).aspxReplyDeleteRepliesReplyDavid HeffernanJanuary 9, 2015 at 4:46 AMLars Fosdal They work as well as ever, but are platform specific. For x-plat you use UnicodeFromLocaleChars and LocaleCharsFromUnicodeReplyDeleteRepliesReplySam Shaw (è•æ²–)January 9, 2015 at 11:33 PMPlease refer to my answer:rbstr := pastr; // assign PAnsiChar to RawByteString // assume text encoded as codepage 936 // Note here: set 3rd param to false! SetCodePage(rbstr,936,false); ustr := string(rbstr);http://stackoverflow.com/questions/27857479/whats-the-correct-way-to-assign-pansichar-to-a-unicode-string/27873918#27873918ReplyDeleteRepliesReplyAdd commentLoad more... Post a Comment
Back in the pre-Unicode days, it was MultiByteToWideChar/WideCharToMultiByte that was the go-to tools for code page and character set conversion. http://msdn.microsoft.com/en-us/library/windows/desktop/dd319072(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/windows/desktop/dd374130(v=vs.85).aspx Both require you to know the CP of the source/target.
ReplyDeleteMore info: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317752(v=vs.85).aspx
Lars Fosdal They work as well as ever, but are platform specific. For x-plat you use UnicodeFromLocaleChars and LocaleCharsFromUnicode
ReplyDeletePlease refer to my answer:
ReplyDeleterbstr := pastr; // assign PAnsiChar to RawByteString
// assume text encoded as codepage 936
// Note here: set 3rd param to false!
SetCodePage(rbstr,936,false);
ustr := string(rbstr);
http://stackoverflow.com/questions/27857479/whats-the-correct-way-to-assign-pansichar-to-a-unicode-string/27873918#27873918