HttpJob 返回数据格式未知

liusong

Member
1645356746071.png




j.GetString 接收到的是 加密还是其它编码 这个是扫描编码格式或者 密文? H4slAAAAAAAEAKtWSs5PSVWysrTUUcotTIeyUvL3VqoFALdFALdGW0kWAAAAAA==
 

drgottjr

Expert
Licensed User
Longtime User
j.GetString 返回 UTF-8 文本。
如果你不想要 UTF-8,你需要 j.GetString2( encoding )

"H4slAAAAAAAEAKtWSs5PSVWysrTUUcotTIeyUvL3VqoFALdFALdGW0kWAAAAAA=="
看起来像 Base64。 Base64 可以解码为文本(ASCII 或 UTF-8),但也可以
返回二进制。 二进制字符串可能需要进一步处理。
J.GetString fǎnhuí UTF-8 wénběn.
Rúguǒ nǐ bùxiǎng yào UTF-8, nǐ xūyào j.GetString2(encoding)
二进制字符串可以被加密
Èrjìnzhì zìfú chuàn kěyǐ bèi jiāmì
--------------------------------------------------------------------------------------------------------
j.GetString returns UTF-8 text.
if you do not want UTF-8, you need j.GetString2( encoding )

"H4slAAAAAAAEAKtWSs5PSVWysrTUUcotTIeyUvL3VqoFALdFALdGW0kWAAAAAA=="
looks like Base64. Base64 can be decoded to text (ASCII or UTF-8), but it can also
return binary. A binary string may require further handling. the binary string could be
encrypted.
 

liusong

Member
😊这个服务器上回复是中文 不是Base64 我试过啦 GetString2 也没用;同样的 WEBAPI 我部署了2台服务器,一个返回正常,一个是乱码; 不知道是不是WEBAPI的问题?
 

drgottjr

Expert
Licensed User
Longtime User
“这台服务器上的回复是中文的,不是Base64的。”

如果 "H4slAAAAAAAEAKtWSs5PSVWysrTUUcotTIeyUvL3VqoFALdFALdGW0kWAAAAAA==" 是回复,
它不是中国人。 看人物; 他们不是汉字。 它们是拉丁/ASCII字符。
如果我假设 Base64 并解码为中文,我会看到一些中文字符,但有几个不同的
中文字符集。


“我试过 GetString2,但没有用;”
您使用了哪种编码? 你说的是哪个汉字集?


“我为同一个WEBAPI部署了2台服务器,一台返回正常,另一台出现乱码;
不知道是不是WEBAPI的问题?”

如果您向 2 个不同的服务器提出相同的问题并且收到 2 个不同的答案(其中 1 个是正确的),
我会怀疑我使用多年的其他服务器,而不是 okhttp。
另外,webapi 不是 okhttputils。 这是一个不同的api。 我不熟悉它。 对不起
“Zhè tái fúwùqì shàng de huífù shì zhōngwén de, bùshì Base64 de.”

Rúguǒ"H4slAAAAAAAEAKtWSs5PSVWysrTUUcotTIeyUvL3VqoFALdFALdGW0kWAAAAAA==" shì huífù,
tā bùshì zhōngguó rén. Kàn rénwù; tāmen bùshì hànzì. Tāmen shì lādīng/ASCII zìfú.
Rúguǒ wǒ jiǎshè Base64 bìng jiěmǎ wéi zhōngwén, wǒ huì kàn dào yīxiē zhōngwén zìfú, dàn yǒu jǐ gè bùtóng de
zhōngwén zìfú jí.


“Wǒ shìguò GetString2, dàn méiyǒu yòng;”
nín shǐyòngle nǎ zhǒng biānmǎ? Nǐ shuō de shì nǎge hànzì jí?


“Wǒ wèi tóng yīgè WEBAPI bùshǔle 2 tái fúwùqì, yī tái fǎnhuí zhèngcháng, lìng yī tái chūxiàn luànmǎ;
bù zhīdào shì bùshì WEBAPI de wèntí?”

Rúguǒ nín xiàng 2 gè bùtóng de fúwùqì tíchū xiāngtóng de wèntí bìngqiě shōu dào 2 gè bùtóng de dá'àn (qízhōng 1 gè shì zhèngquè de),
wǒ huì huáiyí wǒ shǐyòng duōnián de qítā fúwùqì, ér bùshì okhttp.
Lìngwài,webapi bùshì okhttputils. Zhè shì yīgè bùtóng de api. Wǒ bù shúxī tā. Duìbùqǐ

----------------------------------------------------------------------------------------------------------------------
"The reply on this server is Chinese, not Base64."

if "H4slAAAAAAAEAKtWSs5PSVWysrTUUcotTIeyUvL3VqoFALdFALdGW0kWAAAAAA==" is the reply,
it is not chinese. look at the characters; they are not chinese characters. they are latin/ascii characters.
if I assume Base64 and decode to chinese, i see some chinese characters, but there several different
chinese character sets.


"I tried GetString2, but it didn't work;"
which encoding did you use? which chinese character set are you talking about?


"I deployed 2 servers for the same WEBAPI, one returned normal and the other was garbled;
I don't know if it is a WEBAPI problem?"

if you ask the same question to 2 different servers and you receive 2 different answers (and 1 is correct),
I would suspect the other server, not okhttp, which i have used for many years.
also,webapi is not okhttputils. it is a different api. i am not familiar with it. sorry
 

liusong

Member
谢了,解决了;
b4a用这个函数解决
Public Sub GetDecodeBase64Gzipstr(GZIPSTR As String) As String
Dim getjystr As String=""
Dim decompressed() As Byte
Dim su As StringUtils
decompressed=su.DecodeBase64(GZIPSTR)
getjystr = BytesToString(decompressed,0, decompressed.Length, "UTF8")
Return getjystr
End Sub
 

teddybear

Well-Known Member
Licensed User
服务器端查看poststring内容。是否后台收到的内容有问题。
 
Top