Home > Back-end >  Delphi XE5 Base64 decoding Big5 string met some garbled.
Delphi XE5 Base64 decoding Big5 string met some garbled.

Time:09-26

Test string: p9o/p9quYQ==
Correct analytic results: I love my family
Test result: me? My family (lost love words)
The test code:
//USES Soap. EncdDecd
The function DecodeBase64Str2: string;
Var
InStr, OutStr: TStringStream;
The begin
InStr:=TStringStream. Create (' p9o/p9quYQ==');
InStr. SaveToFile (' c: \ 1. TXT);//output results: p9o/p9quYQ==right
Try
OutStr:=TStringStream. Create (");
Try
DecodeStream (InStr, OutStr);
OutStr. SaveToFile (' c: \ 2. TXT);
//output results: и? и is produced, the right should be и 稲 и production
//software will be the third aspects according to Big5 code character to check for me? My family
//at this time have been lost, "love" word
Result:=TEncoding GetEncoding (950). Get string (OutStr. Bytes);//the Big5 code into gb2312
//the Result:='me? My home '
The finally
OutStr. Free;
end;
The finally
InStr. Free;
end;
end;

CodePudding user response:

http://bbs.csdn.net/topics/380108122

CodePudding user response:

reference 1st floor aqtata response:
http://bbs.csdn.net/topics/380108122

Use EncodeString problem more, you can have a try, my this code can normal solution UTF8, GB2312 (change the code page can be), can be normal work out "I love my family" BASE64 encoding, and above all BIG5 code is not work out, in a test string, such as "pGquYaZupKOmbqFDoUOhQw==" can work out for the normal "everybody is good,,,," is this a "I love my family" solution is not good, words will be dropped

CodePudding user response:

I UE feel LZ test string is a little problem, if the Big5 code, "love" the word was nowhere in the character set, this word is "love" of the traditional corresponding "I love my family" is Base64 p9q3UqfarmE=, after this series of decoding to become "и 稲 made" и
If in a text editor input "I love my family" (string corresponding to the original poster), although the "love" word can come out, but as long as read a save again with Big5 code, immediately become? .
That is to say, it can be seen as text input box to illegal characters on the screen,,

Besides the point, LZ is a force of a traditional library has no word encoding, decoding, of course, because not only the word again? .
"Post, I just see the problem

CodePudding user response:





CodePudding user response:

reference DelisPhi reply: 3/f
I have a problem with UE feel LZ testing string, if the Big5 code, "love" the word was nowhere in the character set, this word is "love" of the traditional corresponding "I love my family" is Base64 p9q3UqfarmE=, after this series of decoding to become "и 稲 made" и
If in a text editor input "I love my family" (string corresponding to the original poster), although the "love" word can come out, but as long as read a save again with Big5 code, immediately become? .
That is to say, it can be seen as text input box to illegal characters on the screen,,

Besides the point, LZ is a force of a traditional library has no word encoding, decoding, of course, because not only the word again? .
Knot stick, I just saw this problem

Sorry, long time no, your answer is positive solution, I now is to use the android client CSDN, not knot, knot, etc on the computer

CodePudding user response:

refer to the second floor crystalmoon response:
Quote: refer to 1st floor aqtata response:

http://bbs.csdn.net/topics/380108122

Use EncodeString problem more, you can have a try, my this code can normal solution UTF8, GB2312 (change the code page can be), can be normal work out "I love my family" BASE64 encoding, and above all BIG5 code is not work out, in a test string, such as "pGquYaZupKOmbqFDoUOhQw==" can work out for the normal "everybody is good,,,," is this a "I love my family" solution is not good, will throw the word


Does "love" is simplified, it is not in the character set, of course can't work out,
  • Related