服务端数据:
JSON格式然后DES加密之后base64转换
Delphi Post获取数据后
由于原有解密程序为D7下使用
Des(Astr:string):string;
String-à是ansistring
现在要在xe版本中使用原有的加密方法时直接替换所有string为ansistring,chr函数为ansichar。
Des(Astr:Ansistring):Ansistring;
解密出字符串用Utf8toAnsi转换后中文奇数个时出现乱码。
Eg:
{"book_isbn":"9787530125434","book_issn":"","book_cn":"","book_barcode":"","book_name":"名人??专著 ","book_keyword":"","book_author":" (??罗曼·罗兰原著 ; 郭琳改写","book_publishing_house":"北京 : 北京少年儿童出版??,"book_edition":"3??,"book_series":"","book_publish_date":" 2010","book_publish_cycle":"","book_binding":"","book_title_page":"","book_text_page":"","book_price":"0.0000","book_type_no":"K835.165.76=41","book_types":"贝多??(Beethoven, ludwing Van 1770-1827) -- 传记 -- 缩写","book_size":"","book_words":"","book_sheet":"","book_pages":"147??: 彩图 ; 24cm","book_object":"贝多??(Beethoven, ludwing Van 1770-1827) -- 传记 -- 缩写","book_abstract":""}
后来输入二进制发现
输入字符串在乱码的位置都出现了3F 怀疑是返回结果为ansistring时转换时出错。
随添加数据labytes:Tbytes;直接把转换结果存入数据后。用Tencoding.UTF8.GetString返回,结果显示正常。
暂时这样处理。
原文地址:https://www.cnblogs.com/jspdelphi/p/9543644.html