鍍金池/ 問(wèn)答/Java  Python  HTML/ GB2312如何轉(zhuǎn)UTF-8?

GB2312如何轉(zhuǎn)UTF-8?

GB2312如何轉(zhuǎn)UTF-8?使用對(duì)照表還是有算法?

回答
編輯回答
悶油瓶

看各個(gè)平臺(tái),一般都有現(xiàn)成的庫(kù),我最近用的 平臺(tái)是react-native
庫(kù)名iconv
`const getBookChapter = function(chapter, book) {
return new Promise((resolve, reject) => {

axios({
  method: 'get',
  url: chapter.url,
  responseType: 'arraybuffer'
}).then(res => {
  let dom = iconv.decode(new Buffer(res.data), book.source.encoding)
  resolve(catchBookChapterContent(dom, book.source))
})

})
}`

2017年3月22日 16:40
編輯回答
嘟尛嘴
'GB2312的字節(jié)'.decode('gb2312').encode('utf-8')
2018年5月7日 04:10