I have std :: string with UTF-8 characters.I want to convert a string to its closest equivalent with ASCII characters.
For instance:
Lodz => LodzAssunção => AssuncaoSchloß => Schloss
Unfortunately, the ICU library is unrealistic, and I did not find good documentation on its use, so it would take me too much time to learn how to use it. Time that I don’t have.
Can someone give a small example on how this can be done?thanks.
I don’t know about the ICU, but ICONV does this and is pretty easy to recognize. it's only about 3-4 calls, and in your case you need to use the ICONV_SET_TRANSLITERATE flag using iconvctl() .
ICONV_SET_TRANSLITERATE
iconvctl()
Try this, ucnv_convert ("US-ASCII", "UTF-8", targeting, targetize, source, sourcesize, pError)
I wrote a callback that decomposes and then does some replacement. This can probably be implemented as transliteration. the code is decompcb.c here, and the title is next. Install it in a Unicode-ASCII converter as follows:
ucnv_setFromUCallBack(gConverter, &UCNV_FROM_U_CALLBACK_DECOMPOSE, &status);
then use gConverter to convert from Unicode to ASCII
This is not an area in which I am an expert, but if you do not have a convenient library that makes this easy for you, then it might be best for you to create a table / search map that contains UTF-8 → ASCII values. i.e. The key is UTF-8 char, the value is a sequence of ASCII characters.
Decomposition ß-> ss tells me that you want to decompose compatibility. In ICU, for this you need the Normalizer class. Subsequently, you will have something like L'odz '. From this line, you can simply remove non-ASCII characters. There is no need for an ICU, a normal STL will do.
Source: https://habr.com/ru/post/1277517/More articles:C #: Non-Winforms way to exit the application? - c #Re-center modal popup with javascript - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1277514/offline-access-to-moinmoin-wiki-using-google-gears&usg=ALkJrhj0uk-ARcIaX600A2xapZ_Bn8plCAWhat is the most important feature in Mono 2.0? - monoHow to change the index page for rails? - ruby-on-railsHow to determine axapta class name from class id? - microsoft-dynamicsThe best language for non-programmer technicians to learn - xmlHow to get user and group information in Perl on Windows? - windowsLINQ to XML does not receive data with a set of schemas - xmlVisual Studio to Eclipse Migration Guide - eclipseAll Articles