复制代码 代码如下:
public class encntest
{
public static void main(string args[])
{
byte buf[] = args[0].getbytes();
boolean halfchinese = false;
for(int i=0;i
{
if(halfchinese)
{
byte ch[] = {buf[i-1],buf[i]};
system.out.println("索引"+(i-1)+"位置为中文("+new string(ch)+")");
halfchinese = false;
continue;
}
if((buf[i] & 0x80) == 0)
{
system.out.println("索引"+i+"位置是英文("+(char)buf[i]+")");
}
else
{
halfchinese = true;
}
}
}
}
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!