使base64解码的文本可见而无需更改“非unicode程序设置的Windows语言”; " [英] making a base64 decoded text visible without changing "windows language for non unicode program settings" "

查看:108
本文介绍了使base64解码的文本可见而无需更改“非unicode程序设置的Windows语言”; "的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用base64编码工具(如Indy工具)在TMemo中编码了文本,但是在对结果文本进行解码之后,我只是得到一些?字符而不是正确的文本。
的原文是波斯语。

I encoded a text in a TMemo using base64 encoding tools ( like Indy tools ) but after decoding the result text, I just get some " ? " characters instead of the correct text . the original text is in persian language .

问题是:

我可以看到如果我将波斯语设置为Windows非Unicode程序的语言,则为解码文本。但是我想使解码的文本可见而无需更改 Windows non unicode ...。

I can see the decoded text if I set the windows"language for non unicode programs " on persian language . but I wanna make the decoded text visible without changing the " windows non unicode ... " .

大约两个星期,我被困在了这里!我尝试了 UTF8ToWideString, UTF8ToUTF16, UTF8ToUnicodeString, UTF8ToString, UTF8Decode和 UTF8EncodeToShortString,但它们都不起作用。

Its about two weeks Im stuck on this ! I tried "UTF8ToWideString" , "UTF8ToUTF16","UTF8ToUnicodeString","UTF8ToString","UTF8Decode" and "UTF8EncodeToShortString" but non of them worked.

编码>

  var input,output:TstringStream;
    begin
    input:=nil;
    output:=nil;
    input:=TstringStream.Create;
    output:=TstringStream.Create;
    memo1.Lines.SaveToStream(input);

    input.Position:=0;
    encoder.Encode(input,output);
    output.Position:=0;
    memo2.Clear;
    memo2.Lines.LoadFromStream(output);
    input.Free;
    output.Free
    end; 

解码>>

var input,output:TStringStream;
  begin
  memo3.Clear;
  input:=nil;
  output:=nil;
  input:=TStringStream.Create();
  output:=TStringStream.Create();
  memo2.Lines.SaveToStream(input);
  input.Position:=0;
  decoder.DecodeBegin(output);
  decoder.Decode(input);
  decoder.DecodeEnd;
  output.Position:=0 ;
  memo3.Lines.Add(output.DataString);
   end;

我还尝试了delphi内部编码工具。如下

I also tried delphi internal encoding tools . as following

// encoding >
memo2.Lines.Add(EncodeString(memo1.Lines.Text))
// decoding>

 memo3.lines.add(DecodeString(memo2.Lines.Text)) ;


推荐答案

尝试类似以下操作:

memo2.Text := TIdEncoderMIME.EncodeString(memo1.Text, IndyUTF8Encoding);

memo3.Text := TIdEncoderMIME.DecodeString(memo2.Text, IndyUTF8Encoding);

这篇关于使base64解码的文本可见而无需更改“非unicode程序设置的Windows语言”; "的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆