X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fmb-utf-8.h;h=a683e7afc66e2065dc0013e14aad3c40992a5a54;hb=3aca7317dd930beecbddba646284279744087e69;hp=bd6323aa007aaf6b55c1d0446dde2cda129ca6f9;hpb=0fdc209fda776f7f27f0aa95c0ef369b7bb1c711;p=chise%2Fxemacs-chise.git- diff --git a/src/mb-utf-8.h b/src/mb-utf-8.h index bd6323a..a683e7a 100644 --- a/src/mb-utf-8.h +++ b/src/mb-utf-8.h @@ -1,4 +1,4 @@ -/* Header for UTF-8 buffer/string representation. +/* Header for UTF-8 string representation. Copyright (C) 1999 Electrotechnical Laboratory, JAPAN. Licensed to the Free Software Foundation. @@ -19,11 +19,16 @@ along with XEmacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* Rewritten by MORIOKA Tomohiko . */ +/* Author: MORIOKA Tomohiko . */ #ifndef _XEMACS_MB_UTF_8_H #define _XEMACS_MB_UTF_8_H +#define MULTIBYTE + +/* Maximum number of buffer bytes per Emacs character. */ +#define MAX_EMCHAR_LEN 6 + /************************************************************************/ /* Operations on individual bytes */ /* in a Mule-formatted string */ @@ -31,10 +36,42 @@ Boston, MA 02111-1307, USA. */ /* Does this byte represent the first byte of a character? */ -INLINE int +INLINE_HEADER int BUFBYTE_FIRST_BYTE_P(Bufbyte c); +INLINE_HEADER int BUFBYTE_FIRST_BYTE_P(Bufbyte c) { return (c <= 0x7f) || (0xc0 <= c); } + +/************************************************************************/ +/* Dealing with characters */ +/************************************************************************/ + +/* Is this character represented by more than one byte in a string? */ + +#define CHAR_MULTIBYTE_P(c) ((c) >= 0x80) + + +INLINE_HEADER int REP_BYTES_BY_FIRST_BYTE (int fb); +INLINE_HEADER int +REP_BYTES_BY_FIRST_BYTE (int fb) +{ + if ( fb < 0xc0 ) + return 1; + else if ( fb < 0xe0 ) + return 2; + else if ( fb < 0xf0 ) + return 3; + else if ( fb < 0xf8 ) + return 4; + else if ( fb < 0xfc ) + return 5; + else + return 6; +} + + +#include "mb-multibyte.h" + #endif /* _XEMACS_MB_UTF_8_H */