00001 #ifndef LIBSHERPA_UTF8_HXX 00002 #define LIBSHERPA_UTF8_HXX 00003 00004 /************************************************************************** 00005 * 00006 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, The EROS 00007 * Group, LLC. 00008 * Copyright (C) 2004, 2005, 2006, Johns Hopkins University. 00009 * All rights reserved. 00010 * 00011 * Redistribution and use in source and binary forms, with or 00012 * without modification, are permitted provided that the following 00013 * conditions are met: 00014 * 00015 * - Redistributions of source code must contain the above 00016 * copyright notice, this list of conditions, and the following 00017 * disclaimer. 00018 * 00019 * - Redistributions in binary form must reproduce the above 00020 * copyright notice, this list of conditions, and the following 00021 * disclaimer in the documentation and/or other materials 00022 * provided with the distribution. 00023 * 00024 * - Neither the names of the copyright holders nor the names of any 00025 * of any contributors may be used to endorse or promote products 00026 * derived from this software without specific prior written 00027 * permission. 00028 * 00029 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00030 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00031 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00032 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00033 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00034 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00035 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00036 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00037 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00038 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00039 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00040 * 00041 **************************************************************************/ 00042 00043 #include <stdint.h> 00044 00045 namespace sherpa { 00046 00047 // Decode a UTF-8 character, returning the start of next character via 00048 // snext. Note that this decoder ignores the recent ISO-10646 00049 // resolution, and works for private code points. 00050 uint32_t 00051 utf8_decode(const char *s, const char **snext); 00052 00053 // Returns encoding via utf8 array, length as result. 00054 unsigned 00055 utf8_encode(uint32_t ucs4, char utf8[7]); 00056 00057 } 00058 #endif /* LIBSHERPA_UTF8_HXX */
1.4.7