"Fossies" - the Fresh Open Source Software Archive

Member "teapot-2.3.0/utf8.h" (6 Feb 2012, 1293 Bytes) of package /linux/privat/old/teapot-2.3.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "utf8.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2     UTF-8 wrapper for teapot
    3     Copyright (C) 2010 Joerg Walter
    4 
    5     This program is free software: you can redistribute it and/or modify
    6     it under the terms of the GNU General Public License as published by
    7     the Free Software Foundation, either version 3 of the License, or
    8     (at your option) any later version.
    9 
   10     This program is distributed in the hope that it will be useful,
   11     but WITHOUT ANY WARRANTY; without even the implied warranty of
   12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13     GNU General Public License for more details.
   14 
   15     You should have received a copy of the GNU General Public License
   16     along with this program.  If not, see <http://www.gnu.org/licenses/>.
   17 */
   18 
   19 #ifndef UTF8_H
   20 #define UTF8_H
   21 
   22 #include <sys/types.h>
   23 #include "config.h"
   24 
   25 #ifdef __cplusplus
   26 extern "C" {
   27 #endif
   28 
   29 size_t mbslen(const char *str);
   30 char *mbspos(const char *str, int ch);
   31 
   32 #ifdef ENABLE_UTF8
   33 
   34 #define UTF8SZ 4
   35 static inline int is_mbcont(unsigned char c)
   36 {
   37     return (c >= 0x80 && c < 0xc0);
   38 }
   39 
   40 static inline int is_mbchar(unsigned char c)
   41 {
   42     return (c >= 0x80);
   43 }
   44 
   45 #else
   46 
   47 #define UTF8SZ 1
   48 static inline int is_mbcont(unsigned char c)
   49 {
   50     return 0;
   51 }
   52 
   53 static inline int is_mbchar(unsigned char c)
   54 {
   55     return 0;
   56 }
   57 
   58 #endif
   59 
   60 #ifdef __cplusplus
   61 }
   62 #endif
   63 
   64 #endif