Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

c++ - How to read file which contains uxxxx in vc++

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

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

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...