c++unicodeencoding

How to convert "\u002f" to "/" (in c++)?


I have to following string which i get from share point : \u002fsites\u002fblabla\u002fShared Documents\u002fkittens.xml

and i'm trying to convert it to : /sites/blabla/Shared Documents/kittens.xml

I googled it and found that it is Unicode encoded, but i couldn't find anything that converts it, technically i can write a small function that converts all the "\u002f" to "/" but i don't think it is the right thing to do.

If any one can shed some light on this matter it would be very helpful.

Thanks


Solution

  • I found a library that solved my problem, and i want to share the solution in case someone else will stumble upon this question.

    The library called ICU

    And the use is very simple :

    icu::UnicodeString converter = icu::UnicodeString(in.c_str(),in.length());
    icu::UnicodeString newUstring = converter.unescape();
    newUstring.toUTF8String(out);
    

    when in and out are string.