1

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?

user2724841
  • 41
  • 1
  • 2
  • 9
  • 2
    Can you post the code? – Jesse Good Aug 29 '13 at 09:07
  • First thing is to detect what the browser encoding is so you can make the right choice. Are you asking for help about that, or have you got that figured out and are asking for help to do the UTF-8 conversion? – john Aug 29 '13 at 09:20
  • How can I detect browser settings for future refence. I have tried searching the html headers for encoding but can't seem to find the encoding there. – user2724841 Aug 29 '13 at 09:28
  • The problem at hand now would be the UTF-8 conversion – user2724841 Aug 29 '13 at 09:29
  • I wrote some UTF-8 to UTF-16 conversion code a while back and posted it here. http://stackoverflow.com/questions/7153935/how-to-convert-utf-8-stdstring-to-utf-16-stdwstring/7154226#7154226 . Won't help with the URL encoding however. (I'm assuming that what you call Unicode is actually UTF-16, which would make sense on a Windows machine, since Windows uses UTF-16 internally, but if not you need to specify more precisely what your target is for the conversion) – john Aug 29 '13 at 09:31
  • The code has now been posted up – user2724841 Aug 29 '13 at 09:34

1 Answers1

3

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

Steven R. Loomis
  • 4,228
  • 28
  • 39