Converting character encoding within c++

为君一笑 提交于 2021-01-28 12:32:13

问题


I have a website which allows users to input usernames.

The problem here is that the code in c++ assumes the browser encoding is Western Europe and converts the string received from the username text box into unicode to compare with string stored within the databasse.

with the right browser encoding set the character úser is recieved as %FAser and coverted properly to úser within the program however with the browser settings set to UTF-8 the string is recieved as %C3%BAser and then converted to úser due to the code converting C3 and BA as seperate characters.

Is there a way to convert the example %c3%BA to ú while ensuring the right conversions are being made?


回答1:


You can use the ICU library to convert between almost all usable encodings. This library also provides lots of string manipulation facilities.



来源:https://stackoverflow.com/questions/18506588/converting-character-encoding-within-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!