From 9e11577128c92707c2db3f3e44814a3be0d7bf6f Mon Sep 17 00:00:00 2001 From: piaip Date: Thu, 17 Apr 2008 01:47:43 +0000 Subject: - (internal) visio: add vgets - (internal) add key name KEY_BS2 - (internal) move getDBCSstatus to DBCS_Status git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4174 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- common/sys/string.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'common') diff --git a/common/sys/string.c b/common/sys/string.c index 881a0e04..908f1fb4 100644 --- a/common/sys/string.c +++ b/common/sys/string.c @@ -311,6 +311,26 @@ int DBCS_RemoveIntrEscape(unsigned char *buf, int *len) return (oldl != l) ? 1 : 0; } +int DBCS_Status(const char *dbcstr, int pos) +{ + int sts = DBCS_ASCII; + const unsigned char *s = (const unsigned char*)dbcstr; + + while(pos >= 0) + { + if(sts == DBCS_LEADING) + sts = DBCS_TRAILING; + else if (*s >= 0x80) + { + sts = DBCS_LEADING; + } else { + sts = DBCS_ASCII; + } + s++, pos--; + } + return sts; +} + /* ----------------------------------------------------- */ /* 字串檢查函數:英文、數字、檔名、E-mail address */ /* ----------------------------------------------------- */ -- cgit v1.2.3