{"action":"opened","issue":{"url":"https://api.github.com/repos/teramy/react-native/issues/1","repository_url":"https://api.github.com/repos/teramy/react-native","labels_url":"https://api.github.com/repos/teramy/react-native/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/teramy/react-native/issues/1/comments","events_url":"https://api.github.com/repos/teramy/react-native/issues/1/events","html_url":"https://github.com/teramy/react-native/issues/1","id":350349593,"node_id":"MDU6SXNzdWUzNTAzNDk1OTM=","number":1,"title":"react-native网络请求，返回值中文乱码问题","user":{"login":"teramy","id":13774887,"node_id":"MDQ6VXNlcjEzNzc0ODg3","avatar_url":"https://avatars2.githubusercontent.com/u/13774887?v=4","gravatar_id":"","url":"https://api.github.com/users/teramy","html_url":"https://github.com/teramy","followers_url":"https://api.github.com/users/teramy/followers","following_url":"https://api.github.com/users/teramy/following{/other_user}","gists_url":"https://api.github.com/users/teramy/gists{/gist_id}","starred_url":"https://api.github.com/users/teramy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teramy/subscriptions","organizations_url":"https://api.github.com/users/teramy/orgs","repos_url":"https://api.github.com/users/teramy/repos","events_url":"https://api.github.com/users/teramy/events{/privacy}","received_events_url":"https://api.github.com/users/teramy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-14T09:29:56Z","updated_at":"2018-08-14T09:29:56Z","closed_at":null,"author_association":"OWNER","body":"1.       移动应用都需要从远程地址中获取数据或资源，如果远程服务端编码是gbk，你的代码编码是utf-8，在远程服务端不更改编码的情况下，则网络请求Fetch获取到的返回值中有中文会出现乱码的情况。\r\n2.       遇到这个问题只需要舍弃RN的Fetch方法，采用网页端XMLHttpRequest就可以解决数据乱码的问题，而且因为应用和网页端安全机制不同，不会有跨域限制。\r\n\r\n`var request = new XMLHttpRequest();\r\nrequest.onreadystatechange = e => {\r\n  if (request.readyState !== 4) {\r\n    return;\r\n  }\r\n  if (request.status === 200) {\r\n    console.log(\"success\", request.responseText);\r\n  } else {\r\n    console.warn(\"error\");\r\n  }\r\n};\r\n\r\nrequest.open(\"GET\", \"请求地址\");\r\nrequest.send();`"}}
{"actor":{"display_login":"teramy"}}