Sample: International Components for Unicode (ICU)
International Components for Unicode (ICU)
How to reproduce the ICU NLS problem
- download the icu library
- build an empty main()
- add the trouble icu funcation call with NULL parameters
- check the function API document
- fill in all parameters
[1] Download
icu4c-67_1-Win32-MSVC2017.zip
https://github.com/unicode-org/icu/releases/tag/release-67-1
read the readme.html file to see how to build using VS 2015
This download has:
\lib
\include
\bin
icuin.lib, icuuc.lib
////////////////////////
Download the SOURCE CODE you then get the same stuff on work pc including the samples
[2]
Source code.zip
icu-release-67-1.zip
https://github.com/unicode-org/icu/releases/tag/release-67-1
But of course the source code zip does NOT have those dll’s.
[3] Confluence page has ICU building instructions?
[4] Need Visual Studio 2017 to build ICU 67?
Date and Time Formatting Examples
Date and Time Formatting Examples
Date and Time Formatting Examples
http://userguide.icu-project.org/formatparse/datetime/examples
/* 1st example: format the dates in millis 100000000 and
2000000000 */
UErrorCode status=U_ZERO_ERROR;
int32_t i, myStrlen=0;
UChar* myString;
UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
UDateFormat* df = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, “GMT”, &status);
for (i = 0; i < 3; ++i) { myStrlen = udat_format(df, myDateArr[i], NULL, myStrlen, NULL, &status); if(status==U_BUFFER_OVERFLOW_ERROR){ status=U_ZERO_ERROR; myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) ); udat_format(df, myDateArr[i], myString, myStrlen+1, NULL, &status); printf("%s\n", austrdup(myString) ); /* austrdup( a function used to convert UChar* to char*) */ free(myString); } } U_BUFFER_OVERFLOW_ERROR ==>
Is NO problem?
* 2nd example: parse a date with short French date/time
formatter */
UDateFormat* df = udat_open(UDAT_SHORT, UDAT_SHORT, “fr_FR”, “GMT”, &status);
UErrorCode status = U_ZERO_ERROR;
int32_t parsepos=0;
UDate myDate = udat_parse(df, myString, u_strlen(myString), &parsepos,
&status);
locale = “fr_FR”
Need this example using ICU
Convert “20200815160322” to Farsi formata
?ssl=1
Persian (Afhanistan)
https://icu4c-demos-7hxm2n5zgq-uc.a.run.app/icu-bin/locexp?d_=en&_=fa
Month starts: 0 – 11
Looking for simple practical C++ examples of how to use ICU
https://stackoverflow.com/questions/6010793/looking-for-simple-practical-c-examples-of-how-to-use-icu
There are samples within the ICU source tree, under icu/source/samples – I think the converter samples there open and close utf-8, also icu/source/extras/uconv which is an ‘iconv’ like application.
samples
https://begriffs.com/posts/2019-05-23-unicode-icu.html
https://docs.microsoft.com/en-us/windows/win32/intl/international-components-for-unicode–icu-