In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to solve the problem of garbled codes in GBK". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Similar to the following string (GBK), explode does not get the correct result:
1.$result = explode ("|", "Teng Huacheng | Haiqing"); the reason is that for the word "tao" (read tao, it doesn't matter, I don't know either), because his GBK code value is: 8f7c, unfortunately, the ASCII value of "|" is also 7c.
There are many other problems like this: because the encoding range of GBK encoding is 0 × 8140-0xfefe, theoretically, any word with a low byte of 7c will have this problem, such as:
1. (827c), billion (837c), (b17c), (e57c). Wait, wait. For a situation like this,
1. First, you can transcode to utf8, then explode, and then turn back, which is a more troublesome method.
two。 Second, we can use regular "match out" instead of "separate out":
3.preg_match_all ("/ ([/ x81-/xfe] [/ x40-/xfe]) + /", $gbk_str, $matches); / / write dead code so that the array corresponding to index 0 in $matches is the array of the resulting words.
This is the end of the content of "how to solve the problem of garbled codes in GBK Chinese". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.