C++ Builder XE4
https://edn.embarcadero.com/article/39387
のQC# 67686
Description(抜粋):
...
Internally, Lowercase() and UpperCase() are not initializing the ECX register (which is used to hold the target codepage for the new string memory) when calling System.@LStrSetLength(), so whatever random value was already in ECX gets used as the codepage.
Steps:
uses AnsiStrings; var astr : AnsiString; ustr : UnicodeString; cp: Word; begin astr := AnsiStrings.LowerCase('ABCDE'); cp := StringCodePage(astr); // <-- expected 0 or 1252, got random value instead ustr := astr; // <-- conversion to UTF-16 fails, ustr ends up with empty data end;
code page 1252は何か。
Windows-1252 or CP-1252 (code page – 1252) is a 1 byte character encoding of the Latin alphabet, used by default in the legacy components of Microsoft Windows in English and some other Western languages (other languages use different default encodings).
英語版のWindowsにおいて使われているデフォルトのコードページなのだろう。
日本語版でテストしても不具合の再現は難しいかもしれない。
LowerCase()もしくはUpperCase()を使用したときにLStrSetLength()がコールされ、それによる不具合が発生しているのだろうか。