Guide Internationalization Guide Version 2
Total Page:16
File Type:pdf, Size:1020Kb
Guide Internationalization Guide Version 2 HNICA C L E G T U I D E S [This page intentionally left blank] X/Open Guide Internationalisation Guide Version 2 X/Open Company Ltd. July 1993, X/Open Company Limited All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without the prior permission of the copyright owners. X/Open Guide Internationalisation Guide Version 2 ISBN: 1-85912-002-4 X/Open Document Number: G304 Published by X/Open Company Ltd., U.K. Any comments relating to the material contained in this document may be submitted to X/Open at: X/Open Company Limited Apex Plaza Forbury Road Reading Berkshire, RG1 1AX United Kingdom or by Electronic Mail to: [email protected] ii X/Open Guide (1993) Contents Chapter 1 Introduction............................................................................................... 1 1.1 Background.................................................................................................. 1 1.1.1 External Influences .................................................................................. 1 1.1.2 Historical Development ......................................................................... 2 1.2 Internationalisation .................................................................................... 4 1.2.1 Language................................................................................................... 4 1.2.2 Cultural Data ............................................................................................ 4 1.2.3 Character Sets ........................................................................................... 4 1.3 Localisation .................................................................................................. 5 1.3.1 Collating Sequence .................................................................................. 5 1.3.2 Character Classification.......................................................................... 5 1.3.3 Case Conversion ...................................................................................... 5 1.3.4 Language Information ............................................................................ 5 1.3.5 Message Catalogues ................................................................................ 5 1.4 Language Announcement......................................................................... 6 1.5 Terms and Definitions................................................................................ 7 1.5.1 Portable Character Set............................................................................. 7 Chapter 2 Developing Internationalised Software .................................. 9 2.1 Character Sets .............................................................................................. 10 2.1.1 Data Transparency................................................................................... 10 2.1.2 Code Literals............................................................................................. 11 2.1.3 Multi-byte Characters ............................................................................. 12 2.1.4 Trigraphs.................................................................................................... 12 2.1.5 Classification............................................................................................. 13 2.1.6 Conversion................................................................................................ 13 2.1.7 String Comparison................................................................................... 14 2.2 Cultural Data ............................................................................................... 15 2.2.1 The langinfo Database ............................................................................ 15 2.2.2 The nl_langinfo( ) Function.................................................................... 16 2.2.3 The strftime( ) Function .......................................................................... 16 2.2.4 The strfmon( ) Function .......................................................................... 17 2.2.5 The localeconv( ) Function ..................................................................... 17 2.2.6 Other Functions........................................................................................ 17 2.3 Language ...................................................................................................... 18 2.3.1 Messages.................................................................................................... 18 2.3.2 Formatted Output.................................................................................... 19 2.3.3 Formatted Input ....................................................................................... 20 2.4 Initialisation ................................................................................................. 21 2.4.1 General Locale Setting ............................................................................ 21 2.4.2 Internal Locale Settings .......................................................................... 21 Internationalisation Guide Version 2 iii Contents Chapter 3 The Message System............................................................................ 23 3.1 Message Text Source Files......................................................................... 24 3.1.1 General....................................................................................................... 24 3.1.2 The set Directive ...................................................................................... 24 3.1.3 The delset Directive................................................................................. 25 3.1.4 Message Directives.................................................................................. 25 3.1.5 Comments ................................................................................................. 25 3.1.6 Quoting...................................................................................................... 25 3.2 Programming Using Message Files......................................................... 26 3.2.1 Example of Program Referencing Separate Texts ............................. 26 3.2.2 Example of Related Texts (English Version) ...................................... 27 3.2.3 Editing Message Files.............................................................................. 28 3.3 Message Translation................................................................................... 29 3.4 Generating Message Catalogues ............................................................. 31 3.4.1 The gencat Command............................................................................. 31 3.4.2 Multiple Source Files............................................................................... 31 3.4.3 Changing an Existing Message Catalogue ......................................... 31 3.4.4 Portability .................................................................................................. 32 3.5 Message Catalogue Access ....................................................................... 33 3.5.1 NLSPATH .................................................................................................. 33 3.5.2 The catopen( ) Function .......................................................................... 34 3.5.3 The catclose( ) Function .......................................................................... 35 3.6 Reading Program Messages...................................................................... 36 3.6.1 The catgets( ) Function............................................................................ 36 3.6.2 Further Examples..................................................................................... 37 3.6.3 Performance .............................................................................................. 38 Chapter 4 Internationalisation Support Interfaces................................... 39 4.1 Locale Initialisation .................................................................................... 42 4.1.1 The setlocale( ) Function......................................................................... 42 4.1.2 Setting the Program Locale.................................................................... 43 4.1.3 Setting a Specific Category from the Environment .......................... 44 4.1.4 Setting all Categories from the Environment .................................... 44 4.1.5 The POSIX Locale .................................................................................... 44 4.2 Character Classification............................................................................. 48 4.2.1 The iswalnum( ) Function ...................................................................... 48 4.2.2 The iswalpha( ) Function........................................................................ 48 4.2.3 The iswcntrl( ) Function.......................................................................... 48 4.2.4 The iswdigit( ) Function.......................................................................... 48 4.2.5 The iswgraph( ) Function ....................................................................... 49 4.2.6 The iswlower( ) Function.......................................................................