X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fmb-utf-8.h;h=c895a0608a2f6fb003863049799c8865550cb0d1;hb=112b4eb6a71cd613a534b4246b4cc024ed9bf22e;hp=2524e492746766309caaa5daf89128248939a0ee;hpb=d9ca7c8d810c2c90cdcd4dc6de29c1660be8ba08;p=chise%2Fxemacs-chise.git- diff --git a/src/mb-utf-8.h b/src/mb-utf-8.h index 2524e49..c895a06 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,22 +19,28 @@ 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 */ /************************************************************************/ -/* Does this byte represent the first byte of a character? */ +/* Does BYTE represent the first byte of a character? */ -INLINE int -BUFBYTE_FIRST_BYTE_P(Bufbyte c) +INLINE_HEADER int BUFBYTE_FIRST_BYTE_P(Bufbyte byte); +INLINE_HEADER int +BUFBYTE_FIRST_BYTE_P(Bufbyte byte) { - return (c <= 0x7f) || (0xc0 <= c); + return (byte <= 0x7F) || (0xC0 <= byte); } @@ -46,6 +52,26 @@ BUFBYTE_FIRST_BYTE_P(Bufbyte c) #define CHAR_MULTIBYTE_P(c) ((c) >= 0x80) -#define CHAR_ASCII_P(c) (!CHAR_MULTIBYTE_P (c)) + +INLINE_HEADER int REP_BYTES_BY_FIRST_BYTE (Bufbyte fb); +INLINE_HEADER int +REP_BYTES_BY_FIRST_BYTE (Bufbyte 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 */