Bonjour,Lors du compilation de code ci dessous, l'erreur suivant apparue
Quelques a une idee !!!!
user@Ubuntu:~/workspace/test$ g++ -std=c++0x -g -o code-cvt.o code-cvt.cpp
code-cvt.cpp: In function ‘int main()’:
code-cvt.cpp:50: error: ‘wstring_convert’ is not a member of ‘std’
code-cvt.cpp:50: error: ‘codecvt_utf8’ is not a member of ‘std’
code-cvt.cpp:50: error: expected primary-expression before ‘wchar_t’
code-cvt.cpp:50: error: expected ‘;’ before ‘wchar_t’
code-cvt.cpp:51: error: ‘conv1’ was not declared in this scope
code-cvt.cpp:56: error: ‘wstring_convert’ is not a member of ‘std’
code-cvt.cpp:56: error: ‘codecvt_utf16’ is not a member of ‘std’
code-cvt.cpp:56: error: expected primary-expression before ‘wchar_t’
code-cvt.cpp:56: error: expected ‘;’ before ‘wchar_t’
code-cvt.cpp:57: error: ‘conv2’ was not declared in this scope
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #include <iostream> #include <string> #include <locale> #include <c++/4.4/bits/codecvt.h> #include <iomanip> int main() { // wide character data std::wstring wstr = L"z\u00df\u6c34\U0001d10b"; // or L"zß水𝄋" // wide to UTF-8 std::wstring_convert<std::codecvt_utf8<wchar_t>> conv1; std::string u8str = conv1.to_bytes(wstr); std::cout << "UTF-8 conversion produced " << u8str.size() << " bytes:\n"; // wide to UTF-16le std::wstring_convert<std::codecvt_utf16<wchar_t, 0x10ffff, std::little_endian>> conv2; std::string u16str = conv2.to_bytes(wstr); std::cout << "UTF-16le conversion produced " << u16str.size() << " bytes:\n"; }
Partager