Languages Around The World

Normalization Examples

Normalize a String

The following examples normalize a string, based on the mode, using the canonical decomposition with the option compatibility decomposition and ignoring the hangul syllable options.


C++

UnicodeString source("This is a test.");
UnicodeString result;
UErrorCode status = U_ZERO_ERROR;

Normalize::normalize(source, COMPOSE_COMPAT, IGNORE_HANGUL, result, status);


C

UChar source[50];
int32_t resultLength = 0;
UChar *result = 0;
UErrorCode status = U_ZERO_ERROR;

u_uastrcpy(source, "This is a test.");
resultLength = u_normalize(source, u_strlen(source), 
   UCOL_DECOMP_COMPAT, UCOL_IGNORE_HANGUL, NULL, NULL, status);
result = (UChar*)malloc(sizeof(UChar)*resultLength+1);
u_normalize(source, u_strlen(source), 
   UCOL_DECOMP_COMPAT, UCOL_IGNORE_HANGUL, result, resultLength, status);
result[resultLength] = 0;


Copyright (c) 2000 - 2006 IBM and Others - PDF Version - Feedback: http://icu.sourceforge.net/contacts.html

User Guide for ICU v3.6 Generated 2006-08-31.