Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have txt file whose contents are:

u041fu0435u0440u0432u044bu0439_u0438u043du0442u0435u0440u0430u043au0442u0438u0432u043du044bu0439_u0438u043du0442u0435u0440u043du0435u0442_u043au0430u043du0430u043b

How can I read such file to get result like this:

"Первый_интерактивный_интернет_канал"

If I type this:

string str = _T("u041fu0435u0440u0432u044bu0439_u0438u043du0442u0435u0440u0430u043au0442u0438u0432u043du044bu0439_u0438u043du0442u0435u0440u043du0435u0442_u043au0430u043du0430u043b");

then result in str is good but if I read it from file then it is the same like in file. I guess it is because 'u' becomes 'u'. Is there simple way to convert uxxxx notation to corresponding symbols in C++?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
271 views
Welcome To Ask or Share your Answers For Others

1 Answer

It's not very easy when you're reading in the file. It's easier to do a post-processing step afterwards. You can use Boost::regex to look for the pattern "u[0-9A-Fa-f]{4}", and replace that by the corresponding single character.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...