Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Unaccentify(std::wstring& str)
- {
- static std::map<TCHAR, TCHAR> unaccentMap;
- static bool init = false;
- if (!init)
- {
- unaccentMap.insert(std::pair<TCHAR,TCHAR>(_T('à'),_T('a')));
- unaccentMap.insert(std::pair<TCHAR,TCHAR>(_T('é'),_T('e')));
- unaccentMap.insert(std::pair<TCHAR,TCHAR>(_T('ë'),_T('e')));
- unaccentMap.insert(std::pair<TCHAR,TCHAR>(_T('ù'),_T('u')));
- // ....
- init = true;
- }
- std::map<TCHAR, TCHAR>::iterator mapEnd = unaccentMap.end();
- for (std::wstring::iterator it = str.begin(), end = str.end(); it != end; ++it)
- {
- std::map<TCHAR, TCHAR>::iterator mapIt = unaccentMap.find(*it);
- if ( mapIt != mapEnd)
- {
- *it = mapIt->second;
- }
- }
- }
- void main()
- {
- std::wstring str = _T("De l'été à Noël où va-t-on?");
- Unaccentify(str);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement