C++11语法转换UTF8很方便,记录一下

inline std::wstring to_wide_string(const std::string& input)
{
    std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
    return converter.from_bytes(input);
}

inline std::string to_byte_string(const std::wstring& input)
{
    std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
    return converter.to_bytes(input);
}

int main()
{
    std::string string = to_byte_string(L"中国飘云阁"); // "\xE4\xB8\xAD\xE5\x9B\xBD\xE9\xA3\x98\xE4\xBA\x91\xE9\x98\x81"
    std::wstring wide_string = to_wide_string("\xE4\xB8\xAD\xE5\x9B\xBD\xE9\xA3\x98\xE4\xBA\x91\xE9\x98\x81"); // 中国飘云阁
}

你可能感兴趣的文章

评论区

已有257位网友发表了看法:

1L 游客  2024-07-15 11:08:52 回复
看在楼主的面子上,认真回帖!https://www.11yule.com/153.html
2L 游客  2024-07-15 13:35:41 回复
以后就跟楼主混了!https://sdceda.com/fei/905458660/
3L 游客  2024-07-15 13:44:21 回复
楼主是在找骂么?https://www.henghost.com/
4L 游客  2024-07-15 15:04:15 回复
楼上的说的很多!http://619.zhijian.me
5L 游客  2024-07-15 17:06:52 回复
有品位!https://www.youxixiong.com/70.html
6L 游客  2024-07-15 17:36:31 回复
缺乏激情了!https://sdceda.com/fei/191272559/
7L 游客  2024-07-15 17:37:58 回复
楼上的心情不错啊!https://sdceda.com/fei/230639578/
8L 游客  2024-07-15 21:26:27 回复
网页的加载速度非常快,不会影响用户体验。https://sdceda.com/fei/026006478/
9L 游客  2024-07-15 21:28:00 回复
我只看看不说话。。。http://oniu.ffnbx.net/test/260782331.html
10L 游客  2024-07-15 21:29:28 回复
楼上的别说的那么悲观好吧!https://sdceda.com/fei/176110388/
11L 游客  2024-07-15 21:36:50 回复
顶一个!https://sdceda.com/fei/126272717/
12L 游客  2024-07-16 06:54:17 回复
怎么我回帖都没人理我呢?http://www.zhijian.me/t-56-1-1.html
13L 游客  2024-07-16 08:49:27 回复
楼主写的很经典!http://www.haodianba.com/shuma/28077.html
14L 游客  2024-07-16 10:33:07 回复
我就搞不明白了,看帖回帖能死人么,居然只有我这么认真的在回帖!https://www.mbti.cc
15L 游客  2024-07-16 11:28:16 回复
这个帖子会火的,鉴定完毕!http://knof.ffnbx.net/test/607776837.html
16L 游客  2024-07-16 11:47:51 回复
楼主英明!https://www.uuu9923.cn/3460.html
17L 游客  2024-07-16 13:32:21 回复
楼主好聪明啊!http://32fa.com/Article/4/News_8350.html
18L 游客  2024-07-16 14:30:05 回复
勤奋灌水,天天向上!http://hloi.ffnbx.net/test/791462047.html
19L 游客  2024-07-16 14:49:44 回复
有机会找楼主好好聊聊!http://k7fjcp.zhijian.me
20L 游客  2024-07-16 14:53:01 回复
看帖不回帖都是耍流氓!http://y9fibz.www.noxue.net
21L 游客  2024-07-16 15:54:34 回复
突然觉得楼主说的很有道理,赞一个!http://32fa.com/Article/4/News_8350.html
22L 游客  2024-07-16 16:00:31 回复
楼上的真不讲道理!http://www.zgcpx.cn/c/3741945.html
23L 游客  2024-07-16 16:23:51 回复
楼主是我最崇拜的人!https://sdceda.com/fei/899504038/
24L 游客  2024-07-16 17:04:39 回复
楼主很有激情啊!http://wojl.ffnbx.net/test/770454042.html
25L 游客  2024-07-16 17:27:55 回复
顶!顶!顶!http://vass.ffnbx.net/test/517380876.html
26L 游客  2024-07-16 19:10:59 回复
感觉不错!http://hnjlyzjd.com/hw/wz_20162.html
27L 游客  2024-07-16 19:34:41 回复
楼主很有经验啊!https://www.henghost.com/
28L 游客  2024-07-16 20:45:49 回复
楼上的很有激情啊!http://q5p.zhijian.me
29L 游客  2024-07-16 22:08:09 回复
我就搞不明白了,看帖回帖能死人么,居然只有我这么认真的在回帖!http://www.sm598.com/n/141645242.html
30L 游客  2024-07-16 23:13:01 回复
东方不败外加灭绝师太啊!http://www.yuhua77.com
31L 游客  2024-07-17 03:59:30 回复
看在楼主的面子上,认真回帖!https://img.qupojie.cn/
32L 游客  2024-07-17 08:55:50 回复
世界末日我都挺过去了,看到楼主我才知道为什么上帝留我到现在!http://b9o.0478g.com
33L 游客  2024-07-17 10:03:59 回复
刚分手,心情不好!https://www.henghost.com/
34L 游客  2024-07-17 10:28:24 回复
楼上的这是啥态度呢?https://www.hzscfrp.com
35L 游客  2024-07-17 12:01:56 回复
经典!http://hnjlyzjd.com/xl/wz_21460.html
36L 游客  2024-07-17 16:36:35 回复
很有看点!http://www.pc235.com/game/1325.html
37L 游客  2024-07-18 02:01:29 回复
勤奋灌水,天天向上!http://mt41.https://www.hkdiyi.com/a/23728.html
38L 游客  2024-07-18 03:34:42 回复
顶一个!http://75i8.https://www.weimaitu.com/
39L 游客  2024-07-18 07:46:37 回复
楼主的头像能辟邪啊!http://175kf.com
40L 游客  2024-07-18 12:01:26 回复
没人理我,好伤心啊!https://www.guanzhangtu.com/redianzixun/868.html
41L 游客  2024-07-18 13:08:28 回复
怪事年年有,今年特别多!http://175kf.com
42L 游客  2024-07-18 15:21:10 回复
楼主的等级很高啊!http://n8kr7w.www.szhqty.com/
43L 游客  2024-07-18 16:19:27 回复
知识就是力量啊!https://www.uuu9923.cn/1872.html
44L 游客  2024-07-18 17:06:30 回复
这么经典的话只有楼主能想到!http://etw66.https://www.hkdiyi.com/a/39861.html
45L 游客  2024-07-18 17:29:08 回复
支持一下,下面的保持队形!http://gengsha.cn/dna/305.html
46L 游客  2024-07-18 18:27:49 回复
坚持回帖!http://0yel9.https://www.weimaitu.com/
47L 游客  2024-07-18 20:27:02 回复
看了这么多帖子,第一次看到这么高质量内容!http://175kf.com
48L 游客  2024-07-18 21:11:55 回复
顶顶更健康!http://kbc.www.szhqty.com/
49L 游客  2024-07-18 21:46:05 回复
楼上的心情不错啊!https://www.weimaitu.com/13.html
50L 游客  2024-07-18 21:53:42 回复
大神好强大!https://www.uuu9923.cn/1858.html
51L 游客  2024-07-18 23:30:21 回复
顶一个!http://www.njqqjg.cn
52L 游客  2024-07-18 23:36:35 回复
精华帖的节奏啊!https://www.qupojie.cn/category-azgame.html
53L 游客  2024-07-18 23:45:06 回复
好好学习楼主的帖子!https://weibo.com/ttarticle/p/show?id=2309405057167496708985
54L 游客  2024-07-19 01:04:17 回复
楼主的等级很高啊!http://175kf.com
55L 游客  2024-07-19 01:10:16 回复
小弟默默的路过贵宝地~~~https://www.uuu9923.cn/1872.html
56L 游客  2024-07-19 01:46:11 回复
感谢楼主的推荐!http://175kf.com
57L 游客  2024-07-19 02:38:09 回复
论坛人气好旺!http://a20.www.ywz1.com
58L 游客  2024-07-19 04:20:45 回复
今天上网不回帖,回帖就回精华帖!http://www.yuhua77.com
59L 游客  2024-07-19 04:36:52 回复
被楼主的逻辑打败了!http://175kf.com
60L 游客  2024-07-19 05:57:36 回复
这么经典的话只有楼主能想到!https://www.uuu9923.cn/1858.html
61L 游客  2024-07-19 06:44:03 回复
今天过得很不爽!https://www.uuu9923.cn/1858.html
62L 游客  2024-07-19 06:46:11 回复
楼主你想太多了!http://175kf.com
63L 游客  2024-07-19 08:43:01 回复
楼主今年多大了?http://175kf.com
64L 游客  2024-07-19 09:07:52 回复
这位作者的文笔极其出色,用词精准、贴切,能够形象地传达出他的思想和情感。https://www.uuu9923.cn/1872.html
65L 游客  2024-07-19 09:32:54 回复
我对楼主的敬仰犹如滔滔江水绵延不绝!https://www.uuu9923.cn/1858.html
66L 游客  2024-07-19 09:58:34 回复
勤奋灌水,天天向上!https://www.msl.wang/links/3d99b1cc1f2cdcdaa867.html
67L 游客  2024-07-19 10:13:16 回复
楼主今年多大了?https://www.henghost.com/
68L 游客  2024-07-19 10:45:51 回复
不错哦,楼主这是要火的节奏啊!http://wap.xxklhdu.cn/
69L 游客  2024-07-19 11:06:52 回复
我默默的回帖,从不声张!http://175kf.com
70L 游客  2024-07-19 11:21:52 回复
内容很有深度!https://www.uuu9923.cn/1858.html
71L 游客  2024-07-19 11:29:39 回复
楼主人气很旺!http://175kf.com
72L 游客  2024-07-19 11:36:29 回复
东方不败外加灭绝师太啊!https://www.uuu9923.cn/1858.html
73L 游客  2024-07-19 12:18:54 回复
楼上的真不讲道理!http://e8y.https://www.0478g.com
74L 游客  2024-07-19 12:25:45 回复
收藏了,改天让朋友看看!http://wap.ylyqnuw.cn/
75L 游客  2024-07-19 13:35:10 回复
有机会找楼主好好聊聊!https://www.uuu9923.cn/1872.html
76L 游客  2024-07-19 14:14:13 回复
突然觉得楼主说的很有道理,赞一个!https://weibo.com/tv/show/1034:5057776578134066
77L 游客  2024-07-19 14:29:04 回复
论坛的人气不行了!https://www.kaozn.com/gk/46074.html
78L 游客  2024-07-19 14:31:17 回复
楼主是男的还是女的?http://gsr4d.https://www.0478g.com
79L 游客  2024-07-19 14:48:27 回复
很给力!http://175kf.com
80L 游客  2024-07-19 15:18:59 回复
在这个版块混了这么久了,第一次看见这么给你的帖子!https://m.noncandy.com/game/13255.html
81L 游客  2024-07-19 15:21:17 回复
论坛的人气越来越旺了!https://www.uuu9923.cn/1872.html
82L 游客  2024-07-19 15:36:03 回复
知识就是力量啊!https://www.msl.wang/links/ba223ea6286eb3eab0dd.html
83L 游客  2024-07-19 16:06:13 回复
楼主好聪明啊!https://www.kaozn.com/gk/54614.html
84L 游客  2024-07-19 17:04:44 回复
支持楼上的!https://www.uuu9923.cn/1872.html
85L 游客  2024-07-19 17:32:41 回复
楼主看起来很有学问!https://www.yxmingju.com/sitemap.txt
86L 游客  2024-07-19 18:08:31 回复
你觉得该怎么做呢?https://www.ggplus.cn/70870.html
87L 游客  2024-07-19 18:10:08 回复
文章写太挺好了,真的值得推荐http://175kf.com
88L 游客  2024-07-19 21:05:54 回复
小弟默默的路过贵宝地~~~https://www.uuu9923.cn/1872.html
89L 游客  2024-07-19 23:33:03 回复
这么版块的帖子越来越有深度了!http://mal.www.ywz1.com
90L 游客  2024-07-20 00:00:26 回复
这么版块的帖子越来越有深度了!https://www.uuu9923.cn/1858.html
91L 游客  2024-07-20 01:09:44 回复
对牛弹琴的人越来越多了!http://175kf.com
92L 游客  2024-07-20 01:29:07 回复
楼主是一个神奇的青年!http://www.chinafishingrod.com/rm/9521.html
93L 游客  2024-07-20 01:48:48 回复
顶顶更健康!http://175kf.com
94L 游客  2024-07-20 03:48:29 回复
这篇文章真是让人受益匪浅!https://img.qupojie.cn/
95L 游客  2024-07-20 04:15:11 回复
楼主的等级很高啊!https://www.msl.wang/links/aa2a452edf4546e47d21.html
96L 游客  2024-07-20 04:51:51 回复
网站做得不错https://www.uuu9923.cn/1858.html
97L 游客  2024-07-20 05:06:24 回复
对牛弹琴的人越来越多了!http://175kf.com
98L 游客  2024-07-20 05:47:27 回复
收藏了,很不错的内容!https://www.kaozn.com/gk/21826.html
99L 游客  2024-07-20 08:29:10 回复
祖国尚未统一,我却天天灌水,好内疚!https://www.uuu9923.cn/1858.html
100L 游客  2024-07-20 10:16:16 回复
顶一个!https://www.noncandy.com/game/13205.html

发表评论

必填

选填

选填

必填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。