lcUTF8Load.c revision 61b2299d
1/* $TOG:  $ */
2/******************************************************************
3
4              Copyright 1993 by SunSoft, Inc.
5              Copyright 1999-2000 by Bruno Haible
6
7Permission to use, copy, modify, distribute, and sell this software
8and its documentation for any purpose is hereby granted without fee,
9provided that the above copyright notice appear in all copies and
10that both that copyright notice and this permission notice appear
11in supporting documentation, and that the names of SunSoft, Inc. and
12Bruno Haible not be used in advertising or publicity pertaining to
13distribution of the software without specific, written prior
14permission.  SunSoft, Inc. and Bruno Haible make no representations
15about the suitability of this software for any purpose.  It is
16provided "as is" without express or implied warranty.
17
18SunSoft Inc. AND Bruno Haible DISCLAIM ALL WARRANTIES WITH REGARD
19TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
20AND FITNESS, IN NO EVENT SHALL SunSoft, Inc. OR Bruno Haible BE LIABLE
21FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
23ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
24OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
26******************************************************************/
27/* $XFree86: xc/lib/X11/lcUTF8.c,v 1.12 2001/02/09 00:02:53 dawes Exp $ */
28
29/*
30 * This file contains the UTF-8 locale loader.
31 *     Supports: all locales with codeset UTF-8.
32 *     Platforms: all systems.
33 */
34
35#ifdef HAVE_CONFIG_H
36#include <config.h>
37#endif
38#include <stdio.h>
39#include "Xlibint.h"
40#include "XlcPubI.h"
41#include "XlcGeneric.h"
42
43XLCd
44_XlcUtf8Loader(
45    const char *name)
46{
47    XLCd lcd;
48
49    lcd = _XlcCreateLC(name, _XlcGenericMethods);
50    if (lcd == (XLCd) NULL)
51	return lcd;
52
53    /* The official IANA name for UTF-8 is "UTF-8" in upper case with a dash. */
54    if (!XLC_PUBLIC_PART(lcd)->codeset) {
55	_XlcDestroyLC(lcd);
56	return (XLCd) NULL;
57    }
58    else if (!_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "UTF-8")) {
59        _XlcAddUtf8LocaleConverters(lcd);
60    }
61    else if (!_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "GB18030")) {
62        _XlcAddGB18030LocaleConverters(lcd);
63    }
64    else {
65	_XlcDestroyLC(lcd);
66	return (XLCd) NULL;
67    }
68
69    _XlcAddUtf8Converters(lcd);
70
71    return lcd;
72}
73