Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
134 views
in Technique[技术] by (71.8m points)

javascript - encoding problem at request with json file

I request a JSON file from a server, apparently the file is sent with the wrong encoding header. Unfortunately I don't have the possibility to change the header, because I don't have access to the server. The response contains the strings as Unicode codepoint, e.g. "u00c3u00a4". When I parse the result as JSON it converts to "?¤" expected would be "?".

I am loading the response with Axios, I have already tried to load and convert the response as ArrayBuffel but haven't found the right way yet.

What can I do to correct the encoding on the client side without any adjustments on the server?

example response:

{
  "uid": "",
  "title": "my name",
  "gender": "2",
  "address_title": "",
  "address_firstname": "my",
  "address_lastname": "name",
  "address_zip": "99999",
  "address_city": "xu00c3u00bcxx",
  "address_street": "Bahn Strau00c3u0178e 1",
  "address_name2": "",
  "address_name3": "",
  "phone": "5555",
  "phone_emergency": "55555",
  "fax": "",
  "email": "mail@mail",
  "internet": "",
  "address_alternative_street": "",
  "address_alternative_zip_city": "",
  "job_description": "Gu00c3u00a4rtner",
  "emergency_opening": "",
  "emergency_opening2": "10 - 11 und 17 - 18 Uhr",
  "emergency_description": "",
  "latitude": "",
  "longitude": ""
}

response headers

question from:https://stackoverflow.com/questions/66060047/encoding-problem-at-request-with-json-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...