⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chkctype.gml

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 GML
字号:
.func chkctype
#include <jstring.h>
int chkctype( JCHAR c, int mode );
.ixfunc2 '&Jstring' &func
.funcend
.desc begin
The &func function identifies the type of an 8-bit character.
.np
If
.arg mode
is not
.kw CT_KJ1
then &func identifies whether
.arg c
is the first byte of a double-byte Kanji character.
If
.arg c
is the first byte of a double-byte Kanji character, it returns
.kw CT_KJ1.
If
.arg c
is not the first byte of a double-byte Kanji character, it returns
.kw CT_ANK
or
.kw CT_ILGL.
.np
If
.arg mode
is
.kw CT_KJ1
then &func identifies whether
.arg c
is the second byte of a double-byte Kanji character.
If
.arg c
is the second byte of a double-byte Kanji character, it returns
.kw CT_KJ2.
If
.arg c
is not the second byte of a double-byte Kanji character, it returns
.kw CT_ILGL.
Note that the
.kw nthctype
function identifies the type of the n'th byte of a Kanji string.
.desc end
.return begin
If
.arg c
is a null character,
&func returns
.kw CT_ILGL.
In all other cases, it returns one of
.kw CT_ANK,
.kw CT_KJ1,
.kw CT_KJ2,
or
.kw CT_ILGL.
.begterm 10
.termhd1 Constant
.termhd2 Meaning
.term CT_ANK
(0) The character is a single-byte character (i.e., the byte is not
valid as first byte of a double-byte character).
.term CT_KJ1
(1) The byte is valid as the first byte of a double-byte character.
.term CT_KJ2
(2) The byte is valid as the second byte of a double-byte character
(this value may be returned only when
.arg mode
is
.kw CT_KJ1
.ct ).
.term CT_ILGL
(-1) The byte is not valid as second byte of a double-byte character
or it is the null character,
.endterm
.return end
.see begin
.seelist chkctype nthctype
.see end
.exmp begin
#include <stdio.h>
#include <jstring.h>

static void checkKanji( JMOJI c )
  {
    if( chkctype( c >> 8, CT_ANK ) == CT_KJ1 ) {
      if( chkctype( c & 0xFF, CT_KJ1 ) == CT_KJ2 ) {
        printf( "Char is double-byte Kanji\n" );
      } else {
        printf( "Char is illegal\n" );
      }
    } else {
        printf( "Char is not double-byte Kanji\n" );
    }
  }
.exmp break
void main()
  {
    checkKanji( 'a' );
    checkKanji( (0x81<<8) + 0x55 );
    checkKanji( (0x81<<8) + 0x10 );
  }
.exmp output
Char is not double-byte Kanji
Char is double-byte Kanji
Char is illegal
.exmp end
.class WATCOM
.system

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -