字节 汉字判断

  • XE7

System.UnicodeString.IsLeadSurrogate

bool IsLeadSurrogate(int index)

Tests whether the element is a lead surrogate.

IsLeadSurrogate returns true if the indexed element is a lead surrogate and false otherwise. Note that index is an element index into the string, not a character or byte index.

System.UnicodeString.IsTrailSurrogate

bool         IsTrailSurrogate(int index)

Tests whether the element is a trail surrogate.

IsTrailSurrogate returns True if the indexed element is a trail surrogate and False, otherwise. Note that index is an element index into the string, not a character or byte index.


  • c6

IsLeadByte

IsTrailByte

Returns true if the specified byte is a lead byte.

bool __fastcall IsLeadByte(int index) const;

Description

IsLeadByte returns true if the byte indicated by index (counting from 0) is the lead byte in a multi-byte character. If the byte is a trailing byte, or not part of a multi-byte character, IsLeadByte returns false.

Returns true if the specified byte is of type mbTrailByte.

bool __fastcall IsTrailByte(int index) const;

Description

IsTrailByte returns true if the byte indicated by index (counting from 0) is the trailing byte in a multi-byte character. If the byte is a lead byte, or not part of a multi-byte character, IsTrailByte returns false.

System.SysUtils.TMbcsByteType

TMbcsByteType = (mbSingleByte, mbLeadByte, mbTrailByte);

TMbcsByteType represents the use of a single byte in a string that uses a multi-byte character set (MBCS).

TMbcsByteType represents the possible return values of the ByteType and StrByteType functions. Possible values are as follows.


mbSingleByte


The char is used to represent an entire character in the string. The value of Char cannot be included in the LeadBytes set.


mbLeadByte


The char is used to represent the first byte of a multi-byte character. The value of Char must be included in the LeadBytes set.


mbTrailByte


The char is used to represent one of the trailing bytes in a multi-byte character. There are no a priori restrictions on the value of char.

时间: 2024-08-27 12:04:27

字节 汉字判断的相关文章

read()读取文本字节导致判断失误的问题

工作了几个月,闲着没事又拿起了经典的C程序设计看了起来,看到字符计数一节时想到用read()去读文本作为字符输入,一切OK,直到行计数时问题出现 了,字符总计数没有问题,可行计算就是进行不了,思考了半天又找“大神”帮忙终于找到问题所在了,问题就出在条件判断的char与int的比较上: 问题的关键就在于read()的读取为直接写内存块,当读取一个字节时仅仅把读取到的一个字节写到内存的一个字节的地址上去,当用int类型读取出来时,结果int的前三个字节还是处于垃圾数据的状态,将其与' '一个字节比较

Java 判断是否为汉字 判断是否为乱码 判断字符串是否为双整型数字 整数 数字

/**  * 判断是否为汉字  *   * @param str  * @return  */ public static boolean isGBK(String str) {  char[] chars = str.toCharArray();  boolean isGBK = false;  for (int i = 0; i < chars.length; i++) {   byte[] bytes = ("" + chars[i]).getBytes();   if (

文本输入框和下拉菜单特效-判断汉字的个数

————————————————————————— <script type="text/javascript">                        //进行格式校验            function sumInput(){                //获得文本框的DOM                var myText = document.getElementById("myText");                va

python 包含汉字的文件读写之每行末尾加上特定字符

在数据挖掘中,原始文件的格式往往是令人抓狂,很重要的一步是对数据文件的格式进行整理. 最近,接手的项目里,提供的数据文件格式简直让人看不下去,使用pandas打不开,一直是io error.仔细查看,发现文件中很多行数据是以"结尾,然而其他行缺失,因而需求也就很明显了:判断每行的结尾是否有",没有的话,加上就好了. 采用倒叙的方式好了,毕竟很多人需要的只是一个快速的解决方案,而不是一个why. 解决方案如下: 1 b = open('b_file.txt', w) 2 with ope

短信长度判断:判断是长短信

判断思路: 先筛选出短信内容中包含的中文字符,再用短信内容长度减去中文字符,便得到剩下的字符数,然后算出总字节数 /** * 判断是否是长短信 */ private Integer judgeLongMsg(String tempContent) { //判断短信中有几个中文字符 int count=0; String regex = "[\u4e00-\u9fa5]"; Pattern pattern = Pattern.compile(regex); Matcher matcher

练习:按字节截取字符

import java.io.UnsupportedEncodingException; public class TheLastTestForIO { public static void main(String[] args) throws UnsupportedEncodingException { /* * 按照字节数截取一个字符串,"abc你好"如果截取到半个中文,舍弃. * 比如,截取4个字节,abc,截取五个字节,abc你 * * 字符串-->字节数组.编码 * 字

PHP中判断字符串是否含有中文

<?php /** * [1.测试一] * 当$str = '中文测试'; 时输出"全部是汉字";当$str = '中a文3测试'; 时输出"不全是汉字"; * 应用说明:当某个地方要求用户输入的内容必须全部是中文时,这个就派上用场了. */ $str = '中文测试'; if (preg_match_all("/^([\x81-\xfe][\x40-\xfe])+$/", $str, $match)) { echo '全部是汉字'; }

一个被称为世界上最短的判断IE方法

最近偶然看到一段判断是否为IE浏览器的代码: 1 if(!+[1,]) { 2 console.info("IE 浏览器"); 3 } else { 4 console.info("非 IE浏览器"); 5 } 短短的几个字节就判断出当前浏览器是否为IE浏览器,有意思. 最后看了这里才知道原来是使用了IE浏览器自身编译js代码上的区别才明白: 原来在IE浏览器中如果 +[1,] IE浏览器解析的顺序是[1,].toString()-->'1,' 而 '1,'-

c语言判断是否是utf8字符串,计算字符个数

#include <stdio.h> #include <string.h> #include <stdlib.h> /**************************************************************************** Unicode符号范围 | UTF-8编码方式 (十六进制) | (二进制) 0000 0000-0000 007F:0xxxxxxx 0000 0080-0000 07FF:110xxxxx 10x