消息关闭
    暂无新消息!
新手菜鸟,最近才开始学习Delphi。用的XE2,遇到个问题 关于BASE64的。
XE2中用两个可以编码的方法:Encodestring 和 IdencoderMIME.encodestring
我要实现借助接口上传一个XML:
<?xml version="1.0" encoding="GBK"?>
 <data>
      <InfoKind>0</InfoKind>
      <Name>测试</Name>
      <Code>110101000000001</Code>
      <Account>地址<Account>
      <Phone>电话<Phone>
      <Rate>17</Rate>
      <Notes>备注</Notes>
 </data>
用EncodeString编码,得到:
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iR0JLIj8+DQogPGRhdGE+DQogICAgICA8SW5m
b0tpbmQ+MDwvSW5mb0tpbmQ+CQ0KICAgICAgPE5hbWU+suLK1DwvTmFtZT4JDQogICAgICA8Q29k
ZT4xMTAxMDEwMDAwMDAwMDE8L0NvZGU+CQ0KICAgICAgPEFjY291bnQ+tdjWtzxBY2NvdW50PgkN
CiAgICAgIDxQaG9uZT6157uwPFBob25lPgkNCiAgICAgIDxSYXRlPjE3PC9SYXRlPgkNCiAgICAg
IDxOb3Rlcz6xuNeiPC9Ob3Rlcz4NCiA8L2RhdGE+DQo=

用IdencoderMIME.encodestring编码,得到:
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iR0JLIj8+DQogPGRhdGE+DQogICAgICA8SW5mb0tpbmQ+MDwvSW5mb0tpbmQ+CQ0KICAgICAgPE5hbWU+Pz88L05hbWU+CQ0KICAgICAgPENvZGU+MTEwMTAxMDAwMDAwMDAxPC9Db2RlPgkNCiAgICAgIDxBY2NvdW50Pj8/PEFjY291bnQ+CQ0KICAgICAgPFBob25lPj8/PFBob25lPgkNCiAgICAgIDxSYXRlPjE3PC9SYXRlPgkNCiAgICAgIDxOb3Rlcz4/PzwvTm90ZXM+DQogPC9kYXRhPg==

服务器接到之后,解码:
1.用EncodeString的
<?xml version="1.0" encoding="GBK"?>
 <data>
      <Inf舳栨C?卖栨f舳栨C鄲孝逆諷?,瑿卖?諷鄲孝?鯶fe>110101000000001</Code>
      <Account>地址<Account>
??嗹鍿隵{??嗹鍿鄲孝?FS?s迈&FS鄲孝f <Notes>备注</Notes>
 </data>

2.用IdencoderMIME.encodestring的
<?xml version="1.0" encoding="GBK"?>
 <data>
      <InfoKind>0</InfoKind>
      <Name>??</Name>
      <Code>110101000000001</Code>
      <Account>??<Account>
      <Phone>??<Phone>
      <Rate>17</Rate>
      <Notes>??</Notes>
 </data>

一个汉字乱码,一个汉字变成???

我想问下 要将汉字完整解码出来,我该怎么写?

Encodestring 和 IdencoderMIME.encodestring 区别在哪?

前者76个字符会自动换行,后者为啥不换?

2个回答