11ab64890Smrg/******************************************************************
21ab64890Smrg
31ab64890Smrg              Copyright 1993 by SunSoft, Inc.
41ab64890Smrg              Copyright 1999-2000 by Bruno Haible
51ab64890Smrg
61ab64890SmrgPermission to use, copy, modify, distribute, and sell this software
71ab64890Smrgand its documentation for any purpose is hereby granted without fee,
81ab64890Smrgprovided that the above copyright notice appear in all copies and
91ab64890Smrgthat both that copyright notice and this permission notice appear
101ab64890Smrgin supporting documentation, and that the names of SunSoft, Inc. and
111ab64890SmrgBruno Haible not be used in advertising or publicity pertaining to
121ab64890Smrgdistribution of the software without specific, written prior
131ab64890Smrgpermission.  SunSoft, Inc. and Bruno Haible make no representations
141ab64890Smrgabout the suitability of this software for any purpose.  It is
151ab64890Smrgprovided "as is" without express or implied warranty.
161ab64890Smrg
171ab64890SmrgSunSoft Inc. AND Bruno Haible DISCLAIM ALL WARRANTIES WITH REGARD
181ab64890SmrgTO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
191ab64890SmrgAND FITNESS, IN NO EVENT SHALL SunSoft, Inc. OR Bruno Haible BE LIABLE
201ab64890SmrgFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
211ab64890SmrgWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
221ab64890SmrgACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
231ab64890SmrgOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
241ab64890Smrg
251ab64890Smrg******************************************************************/
261ab64890Smrg
271ab64890Smrg/*
281ab64890Smrg * This file contains the UTF-8 locale loader.
291ab64890Smrg *     Supports: all locales with codeset UTF-8.
301ab64890Smrg *     Platforms: all systems.
311ab64890Smrg */
321ab64890Smrg
331ab64890Smrg#ifdef HAVE_CONFIG_H
341ab64890Smrg#include <config.h>
351ab64890Smrg#endif
361ab64890Smrg#include <stdio.h>
371ab64890Smrg#include "Xlibint.h"
381ab64890Smrg#include "XlcPubI.h"
391ab64890Smrg#include "XlcGeneric.h"
401ab64890Smrg
411ab64890SmrgXLCd
421ab64890Smrg_XlcUtf8Loader(
431ab64890Smrg    const char *name)
441ab64890Smrg{
451ab64890Smrg    XLCd lcd;
461ab64890Smrg
471ab64890Smrg    lcd = _XlcCreateLC(name, _XlcGenericMethods);
481ab64890Smrg    if (lcd == (XLCd) NULL)
491ab64890Smrg	return lcd;
501ab64890Smrg
511ab64890Smrg    /* The official IANA name for UTF-8 is "UTF-8" in upper case with a dash. */
5261b2299dSmrg    if (!XLC_PUBLIC_PART(lcd)->codeset) {
5361b2299dSmrg	_XlcDestroyLC(lcd);
5461b2299dSmrg	return (XLCd) NULL;
5561b2299dSmrg    }
5661b2299dSmrg    else if (!_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "UTF-8")) {
5761b2299dSmrg        _XlcAddUtf8LocaleConverters(lcd);
5861b2299dSmrg    }
5961b2299dSmrg    else if (!_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "GB18030")) {
6061b2299dSmrg        _XlcAddGB18030LocaleConverters(lcd);
6161b2299dSmrg    }
6261b2299dSmrg    else {
631ab64890Smrg	_XlcDestroyLC(lcd);
641ab64890Smrg	return (XLCd) NULL;
651ab64890Smrg    }
661ab64890Smrg
671ab64890Smrg    _XlcAddUtf8Converters(lcd);
681ab64890Smrg
691ab64890Smrg    return lcd;
701ab64890Smrg}
71