Hi, All:
In the FMA , the programe use the utf8encode and
utf8decode function to encode the character to Unicode
and decode the Unicode to the character.
But on the Simplified Chinese Operation System ,
include : Simplified Chinese XP, 2000 and etc. , these
tow function can't work well, so , in the FMA that
always make some error in the follow function: Sync
PhoneBook, Upload a contact to the Phone , Add a
contact to a group , download pics , download sound
and download the theme ...
On the English Edtion OS , doesn't have the above
problem.
Problem Description:
1. Use the Delphi 6E and the Delphi 7E make a small test
program.
2. in the form, Draw two edit controls and two button
controls : Edit1, Edit2, Button1 and Button2.
3. Copy the follow code to the Unit1.pas
----------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
str : string;
str1 : UTF8String;
str2 : string;
pwchar : PWideChar;
begin
str := edit1.Text;
if str <> '' then
begin
GetMem(pwchar, length(str)*2+1);
//Edit2.Text := AnsiToUtf8(str);
StringToWideChar(str, pwchar, length(str)*2+1);
Edit2.Text := Utf8Encode(pwchar);
FreeMem(pwchar);
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Edit1.Text := '';
Edit2.Text := '';
end;
procedure TForm1.Button2Click(Sender: TObject);
var
wstr : WideString;
begin
//Edit2.Text := Utf8ToAnsi(Edit2.Text);
if Edit2.Text <> '' then
begin
wstr := Utf8Decode(Edit2.Text);
edit2.Text := WideCharToString(PWideChar(wstr));
end;
end;
end.
----------------------------------------------
4. Run the test program.
5. in the edit1, input a Chinese character "哈" , and click
the Encode Button, Then we can get the Encoded
charcter "鍝" . copy the Encoded charcter "鍝" into the
edit1 , then click the Decode Button , but can't decode
the charcter.
--------------------------------------------
Encode and Decode Test Table
--------------------------------------------
Test Platform: Simplified Chinese XP
--------------------------------------------
哈 Encode-> 鍝
鍝 Decode-> NULL
哈哈 Encode-> 鍝堝搱
鍝堝搱 Decode-> 哈哈
哈哈哈 Encode-> 鍝堝搱鍝
鍝堝搱鍝 Decode-> NULL
哈哈哈哈 Encode-> 鍝堝搱鍝堝搱
鍝堝搱鍝堝搱 Decode-> 哈哈哈哈
--------------------------------------------
Notes: NULL Means Can't Decode the character.
--------------------------------------------
6. Follow the above test, We can get a result:
In the Simplified Chinese OS, when the character nums
is odd number, the encode and decode function will
make errors, but when the character nums is even
Number, the encode and decode function works well.
Logged In: YES
user_id=933267
Some Correctional Parts:
5. in the edit1, input a Chinese character "" , and click the
Encode Button, Then we can get the Encoded charcter "" .
copy the Encoded charcter "" into the edit1 , then click the
Decode Button , but can't decode the charcter.
--------------------------------------------
Encode and Decode Test Table
--------------------------------------------
Test Platform: Simplified Chinese XP
--------------------------------------------
Encode->
Decode-> NULL
Encode-> 哈哈
哈哈 Decode->
Encode-> 哈哈
哈哈 Decode-> NULL
Encode-> 哈哈哈哈
哈哈哈哈 Decode->
--------------------------------------------
Notes: NULL Means Can't Decode the character.
--------------------------------------------
Test Program GUI
Logged In: YES
user_id=933267
Because the above bugs, the OBEX Folder have some Error,
Look at the follow attach file named OBEX_Folders_bugs.JPG.
OBEX_Folders_bugs.JPG
Logged In: YES
user_id=880616
Ok, you're now a part of the Team, so you can fix it in CVS
three :)
Logged In: YES
user_id=933267
But Now I can't fix it.
In the English Operation System , the problem isn't a problem,
but in the Chinese Operation System, that is a problem, Now,
i am finding out the method to solve the problem.