嘻嘻:)The IsTextUnicode function determines whether a buffer probably contains a form of Unicode text. The function uses various statistical and deterministic methods to make its determination, under the control of flags passed via lpi. When the function returns, the results of such tests are reported via lpi. If all specified tests are passed, the function returns TRUE; otherwise, it returns FALSE.DWORD IsTextUnicode( CONST LPVOID lpBuffer, // pointer to an input buffer to be examined int cb, // the size in bytes of the input buffer LPINT lpi // pointer to flags that condition text examination and receive results );摩托告诉俺di~~:)
Socket ErrorHost name lookup for 'coolslob.ifood1.com' failed
摩托~~回来~~回来~~我不知道怎么用IsTextUnicode呀~~
zswang: J到你邮箱里去了~~btw:你怎么会出这个错呀?直接在IE地址栏输入下载就是呀~~
if IsTextUnicode(pchar(widestring(edit1.text)),length(edit1.Text ),nil)then showmessage('ok')
function FileToString(mFileName: TFileName): string; { 返回从文件载入字符串 } var vFileChar: file of Char; vChar: Char; begin Result := ''; {$I-} AssignFile(vFileChar, mFileName); Reset(vFileChar); while not Eof(vFileChar) do begin Read(vFileChar, vChar); Result := Result + vChar; end; CloseFile(vFileChar); {$I+} end; { FileToString }function StringToDisplay(mString: string): string; var I: Integer; S: string; begin Result := ''; S := ''; for I := 1 to Length(mString) do if mString[I] in [#32..#127] then S := S + mString[I] else begin if S <> '' then begin Result := Result + QuotedStr(S); S := ''; end; Result := Result + Format('#$%x', [Ord(mString[I])]); end; if S <> '' then Result := Result + QuotedStr(S); end; { StringToDisplay }procedure TForm1.Button1Click(Sender: TObject); const cFileName = 'C:\Temp\Script.err'; var S: string; I: Integer; begin S := FileToString(cFileName); for I := Length(S) downto 1 do if S[I] in [#$0..#$8] then Delete(S, I, 1); ShowMessage(Copy(S, 3, MaxInt)); ShowMessage(StringToDisplay(S)); end;
procedure TStrings.SetTextStr(const Value: string); var P, Start: PChar; S: string; tmp: string; begin BeginUpdate; try Clear; tmp := Value; if (Ord(tmp[1]) = $ff) and (Ord(tmp[2]) = $fe) then begin tmp := WideCharToString(PWideChar(Value)); P := Pointer(tmp); end else P := Pointer(Value); if P <> nil then while P^ <> #0 do begin Start := P; while not (P^ in [#0, #10, #13]) do Inc(P); SetString(S, Start, P - Start); Add(S); if P^ = #13 then Inc(P); if P^ = #10 then Inc(P); end; finally EndUpdate; end; end;--晕,,,去年做好的,现在要用,,又给忘了.存到这里来:)
Delphi的VCL不支持Unicode,真是可恶~~偶现在贬为“垃圾”了,以后你扫偶的时候可以幽着点哈,别太粗鲁了~~
历史上, 有两个独立的, 创立单一字符集的尝试. 一个是国际标准化组织(ISO)的 ISO 10646 项目, 另一个是由(一开始大多是美国的)多语言软件制造商组成的协会组织的 Unicode 项目. 幸运的是, 1991年前后, 两个项目的参与者都认识到, 世界不需要两个不同的单一字符集. 它们合并双方的工作成果, 并为创立一个单一编码表而协同工作. 两个项目仍都存在并独立地公布各自的标准, 但 Unicode 协会和 ISO/IEC JTC1/SC2 都同意保持 Unicode 和 ISO 10646 标准的码表兼容, 并紧密地共同调整任何未来的扩展.“还在查资料呢~!”
http://www.unicode.org/unicode/standard/standard.html
在大约 1993 年之后开发的大多数现代编程语言都有一个特别的数据类型, 叫做 Unicode/ISO 10646-1 字符. 在 Ada95 中叫 Wide_Character, 在 Java 中叫 char.ISO C 也详细说明了处理多字节编码和宽字符 (wide characters) 的机制, 1994 年 9 月 Amendment 1 to ISO C 发表时又加入了更多. 这些机制主要是为各类东亚编码而设计的, 它们比处理 UCS 所需的要健壮得多. UTF-8 是 ISO C 标准调用多字节字符串的编码的一个例子, wchar_t 类型可以用来存放 Unicode 字符.
而如何判断,俺不会,估计delphi难
Reply是什么?怎么声明的?
osql -S%s -d%s -U%s -P%s -i%s -o%s\Script.err -u这样输出的Script.err是Unicode文件,使用TStringList.LoadFormFile之后只能显示一丁点(遇到#0之前的那些)
你怎么不去啊?那呆子早就让他的三个GF给搞晕了;
茶要苦的,最便宜的那种;///////省下银子给小小啊;
你要是单纯的显示,可以做出来的,你上次明明上俺判断它的嘛
而且,Unicode 和 String两者去掉#0是一样的;对String没有影响的;
int cb, // the size in bytes of the input buffer
LPINT lpi // pointer to flags that condition text examination and receive results
);摩托告诉俺di~~:)
如果一篇文本以0xff 0xfe开头,那么就是unicode码,否则ansi。
J到你邮箱里去了~~btw:你怎么会出这个错呀?直接在IE地址栏输入下载就是呀~~
{ 返回从文件载入字符串 }
var
vFileChar: file of Char;
vChar: Char;
begin
Result := '';
{$I-}
AssignFile(vFileChar, mFileName);
Reset(vFileChar); while not Eof(vFileChar) do begin
Read(vFileChar, vChar);
Result := Result + vChar;
end;
CloseFile(vFileChar);
{$I+}
end; { FileToString }function StringToDisplay(mString: string): string;
var
I: Integer;
S: string;
begin
Result := '';
S := '';
for I := 1 to Length(mString) do
if mString[I] in [#32..#127] then
S := S + mString[I]
else begin
if S <> '' then begin
Result := Result + QuotedStr(S);
S := '';
end;
Result := Result + Format('#$%x', [Ord(mString[I])]);
end;
if S <> '' then Result := Result + QuotedStr(S);
end; { StringToDisplay }procedure TForm1.Button1Click(Sender: TObject);
const
cFileName = 'C:\Temp\Script.err';
var
S: string;
I: Integer;
begin
S := FileToString(cFileName);
for I := Length(S) downto 1 do
if S[I] in [#$0..#$8] then
Delete(S, I, 1);
ShowMessage(Copy(S, 3, MaxInt));
ShowMessage(StringToDisplay(S));
end;
var
P, Start: PChar;
S: string;
tmp: string;
begin
BeginUpdate;
try
Clear;
tmp := Value;
if (Ord(tmp[1]) = $ff) and (Ord(tmp[2]) = $fe) then
begin
tmp := WideCharToString(PWideChar(Value));
P := Pointer(tmp);
end
else P := Pointer(Value);
if P <> nil then
while P^ <> #0 do
begin
Start := P;
while not (P^ in [#0, #10, #13]) do Inc(P);
SetString(S, Start, P - Start);
Add(S);
if P^ = #13 then Inc(P);
if P^ = #10 then Inc(P);
end;
finally
EndUpdate;
end;
end;--晕,,,去年做好的,现在要用,,又给忘了.存到这里来:)