简体   繁体   English

在C ++中转换字符编码

[英]Converting character encoding within c++

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. 这里的问题是,c ++中的代码假定浏览器编码为西欧,并将从用户名文本框中接收的字符串转换为unicode,以便与存储在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. 在使用正确的浏览器编码集的情况下,字符úser被接收为%FAser,并在程序中正确地覆盖úser ,但是在将浏览器设置为UTF-8的情况下,该字符串被接收为%C3%BAser,然后由于代码而转换为Ãser将C3和BA转换为单独的字符。

Is there a way to convert the example %c3%BA to ú while ensuring the right conversions are being made? 有没有办法在确保正确进行转换的情况下将示例%c3%BA转换为ú?

You can use the ICU library to convert between almost all usable encodings. 您可以使用ICU库在几乎所有可用编码之间进行转换。 This library also provides lots of string manipulation facilities. 该库还提供了许多字符串操作工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM