如何更改unicode
可以使用windows的函数MultiByteToWideChar,WideCharToMultiByte做相互转换.下面是关于这两个函数的说明.如果使用delphi编个程序转换,可以使用StringToWideChar和WideCharToString两个函数实现.The MultiByteToWideChar function maps a character string to a wide-character (Unicode) string. The character string mapped by this function is not necessarily from a multibyte character set. int MultiByteToWideChar( UINT CodePage, // code page DWORD dwFlags, // character-type options LPCSTR lpMultiByteStr, // address of string to map int cchMultiByte, // number of characters in string LPWSTR lpWideCharStr, // address of wide-character buffer int cchWideChar // size of buffer ); The WideCharToMultiByte function maps a wide-character string to a new character string. The new character string is not necessarily from a multibyte character set. int WideCharToMultiByte( UINT CodePage, // code page DWORD dwFlags, // performance and mapping flags LPCWSTR lpWideCharStr, // address of wide-character string int cchWideChar, // number of characters in string LPSTR lpMultiByteStr, // address of buffer for new string int cchMultiByte, // size of buffer LPCSTR lpDefaultChar, // address of default for unmappable characters LPBOOL lpUsedDefaultChar // address of flag set when default char. used );
怎么让C++中字符串编码为utf8,而不是ansi
void Convert(const char* strIn,char* strOut, int sourceCodepage, int targetCodepage){ int len = lstrlenA(strIn); int unicodeLen = MultiByteToWideChar(sourceCodepage, 0, strIn, -1, NULL, 0); wchar_t pUnicode[1024] = {0}; MultiByteToWideChar(sourceCodepage, 0, strIn, - 1, (LPWSTR)pUnicode, unicodeLen); BYTE pTargetData[2048] = {0}; int targetLen = WideCharToMultiByte(targetCodepage, 0, (LPWSTR)pUnicode, -1, (char*)pTargetData,0, NULL, NULL); WideCharToMultiByte(targetCodepage, 0, (LPWSTR)pUnicode, -1,(char*)pTargetData, targetLen, NULL, NULL); lstrcpyA(strOut,(char*)pTargetData);}void UTF82Ansi(PCHAR Src, PCHAR Dst){ Convert(Src,Dst,CP_UTF8,CP_ACP);}void Ansi2UTF8(PCHAR Src, PCHAR Dst){ Convert(Src,Dst,CP_ACP, CP_UTF8);}void TestFunc(){ // ansi转utf8 char* ansi_str = "ansi_str ansi字符串"; char utf_buf[MAX_PATH] = {0}; Ansi2UTF8(ansi_str, utf_buf); // utf8转ansi char ansi_buf[MAX_PATH] = {0}; UTF82Ansi(utf_buf, ansi_buf);}
百科英语 翻译 有文
独自航行 1996年,斯巴鲁独自横穿太平洋。他和其他独自横穿太平洋的人相比,是与众不同的。因为他是独自穿越太平洋的人中,年龄最小的,仅仅14岁。 斯巴鲁于1996年7月22日离开东京。他的船30英尺长(9米)。在船上,他准备了两个月的食物和淡水的给养。同时,他也有一台无线电和航海用的其他现代设备。 在旅程的最开始是非常顺利的,他经常和他的父母通过无线电进行交流,他的船也没有任何问题。但是,在8月11日,船的引擎坏了。突然之间,斯巴鲁失去了电力供应。这一意外影响了航行设备的正常运转。5天之后,他的无线电也停止了工作。此时的他已不能和任何人进行交流。同时他离他的,目的地旧金山还有2770英里远。 一直到8月底,很多人都相信斯巴鲁已经失踪了。没有一个人能通过无线电和他取得联系。他的父母原期望他在9月3日抵达旧金山,但是他没有。但是,在9月13日,斯巴鲁航行到了旧金山。在经历了55天的旅程后,他终于抵达了。 很多人认为斯巴鲁太小了不适合独自航行。他们说,他的父母不应该让他们的孩子进行如此危险的旅行。然而,另一些人却认为,孩子应当有冒险精神,你是怎么想的呢?
百科英语翻译(有文)
Lesson1 The Polynesians
Lesson1波里尼西亚人的
The Polynesians were probably the best explorers in the history of the world. They traveled thousands of kilometers across the Pacific Ocean in large boats called “double canoes. ” They could look at the starts and know which way to go. They also understood the winds and the ocean currents. They made maps of the starts and the ocean currents. They made maps of the sticks and shells.
这个人可能是最好的探险家,在历史上的世界。他们经过数千公里穿越太平洋的大型船只称为“双重划独木舟。“他们可以看开始的时候,知道该走哪条路。他们也了解风力和洋流。他们开始和地图的洋流。他们使地图的棍棒和贝壳。
About 4000 years ago, a group of people lived in southern China. They were a mixture of white, black, and Mongol people. When the Chinese moved farther and farther into the south, these people needed to find safer homes.
大约4000年前,一群人住在中国南部。他们是一个混合的白人,黑人,和蒙古人。当中国移动远到南方,这些人需要找到安全的家园。
Slowly these people left China in their double canoes and started toward the southeast. They took animals and plant with them. A group of people might arrive at an island and stay there until they had children, grandchildren, and great-grandchildren. Then a few families might start traveling again. Some canoes went one way and some another. It took hundreds of years for them to reach all of the islands in Polynesia.
慢慢地这些人离开中国,开始在他们的双重独木舟东南方向。他们把动物和植物。一群人可能抵达一个岛,住在那里,直到他们的孩子、孙子、以及曾孙。然后一些家庭可能会开始旅行一次。一些独木舟走一路和一些另一个。花了好几百年达到所有的岛屿之上。
The double canoe is one of the greatest inventions in history. The Polynesians were among the greatest sailors in history. They understood how to sail by the stars and use the winds and ocean currents. This made them great explorers.
双木船是最伟大的发明之一的历史。这个人在历史上最伟大的航海家。他们懂得航海以天上的星星和使用风和洋流。这使他们伟大的探险家。