Problem Source: http://www.cnblogs.com/del/archive/2008/05/29/1005631.html#1212654
First, this problem may not exist when it reaches Delphi 2008, because tstrings certainly supports Unicode at that time; the current version is 2007.
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs; Type tform1 = Class (tform) memo1: tmemo; Procedure formcreate (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} procedure tform1.formcreate (Sender: tobject); var stream: tmemorystream; PwC: pwidechar; begin stream: = tmemorystream. create; stream. loadfromfile ('C: \ temp \ unicode.txt '); PwC: = stream. memory; // Inc (PWC); {the starting byte may contain garbled characters, so you can remove} memo1.lines. text: = PwC; stream. free; end.
Form of a function:
unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) memo1: tmemo; Procedure formcreate (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} // function for opening Unicode text files: function loadunicodetxt (F: string): ansistring; var stream: tmemorystream; P: pwidechar; begin result: = ''; if not fileexists (f) Then exit; stream: = tmemorystream. create; stream. loadfromfile (f); P: = stream. memory; Inc (p); Result: = P; stream. free; end; // call test: Procedure tform1.formcreate (Sender: tobject); var STR: string; begin STR: = loadunicodetxt ('C: \ temp \ unicode.txt '); memo1.clear; memo1.lines. add (STR); end.