In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1) solution of Chinese garbled code in console
The root of the problem
The reason for the garbled Chinese display is the coding format set by the console. If the encoding format set by the console is GBK and the storage content of the database is UTF-8, of course it cannot be displayed normally.
Solution
1) start CMD to view the current character set encoding, and use the instruction chcp
Active code page:65001: UTF-8 coding
Activity Code Page: 936: GBK Encoding
Note: many users want to be able to enter Chinese under the console. They must use the instruction chcp 936 and switch to GBK encoding format before they can enter Chinese normally.
2) currently view the UTF-8-encoded database file and use the instruction chcp 65001 to switch to the UTF-8-encoded character set
3) enter the directory of the sqlite.exe program, start sqlite.exe, and display the contents of the UTF-8 database normally
4) if the database content is GBK encoded, you can use chcp 936.
2) VS debugging: invalid characters in the string
Scene
The message sent by the network is utf-8-encoded Json data, which is saved in Chinese. When parsing with Jsoncpp, debug the obtained variable in one step. When getting the variable containing Chinese, check the std::string string variable and prompt. The character in the string is invalid.
Analysis
A new feature added in the higher version of VS, if the string contains non-printed characters, or utf8 encoding, the debugger automatically displays: the characters in the string are invalid. It has been misled here that Jsoncpp cannot correctly parse the format of utf-8 encoding. In fact, Jsoncpp has already parsed the content, but it cannot display Chinese in this case. It must be GBK encoding.
Course
Std::string strName = root ["name"] .asString (); / / Chinese characters in name: wind and rain are on the way.
Navigate to strName at this time, indicating that the characters in the string are invalid
Solve
Add strName to monitor. After the name strName, add S8, and it will display normally.
Examples
Name value
StrName,s8 is on its way through wind and rain.
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.