Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Introduction to SourcePro C++
Rogue Wave web site:  Home Page  |  Main Documentation Page

3.3 An Example Using the Internationalization Module with the Threads Module and the C++ Standard Library

This example uses the Internationalization and Threads Modules with the C++ Standard Library to merge two sorted lists into a single sorted list. The input files are encoded in UTF-8 and the resulting list is written to the standard output also in UTF-8. In the program, the strings are converted to UTF-16 as required by the classes of the Internationalization Module. The RWUCollator can then sort the lists using the Unicode Collation Algorithm based on any specified locale.

The standard library supplies the classes for program input and output. The Threads Module is used to implement the producer/consumer model through thread functions (RWThreadFunction) and synchronized queues (RWTPCValQueue). This allows concurrent processing of the two input streams, which could significantly improve performance for large data sets.

Example 2: Using the Internationalization Module with the Threads Module and the C++ Standard Library

The two outputs below demonstrate the difference in sorting based on differing locales. The first uses the default U.S. English locale, the second the Spanish traditional locale, which the example allows you to input at the command line. The two words treated differently are chorizo and llama.

Program output, default en_US Locale

Program output, es__traditional Locale

    Starting merge...
    
    agua
    ahora
    azul
    azur
    blanco
    blanco
    cabeza
    caliente
    chorizo
    curioso
    despues
    donde
    familia
    hombre
    limpio
    llama
    luna
    luz
    madre
    mano
    nombre
    oreja
    padre
    rojo
    rosa
    
    Done.
    
    Starting merge...
    
    agua
    ahora
    azul
    azur
    blanco
    blanco
    cabeza
    caliente
    curioso
    chorizo
    despues
    donde
    familia
    hombre
    limpio
    luna
    luz
    llama
    madre
    mano
    nombre
    oreja
    padre
    rojo
    rosa
    
    Done.
    


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.