package src; public class Main { public static void main(String args[]){ String chinese = "中文 is english"; int clenth = 0; try{ clenth = chinese.getBytes("gbk").length; }catch(Exception e){ clenth = chinese.getBytes().length; } int clenth1 = chinese.length(); if(clenth==clenth1){ System.out.println("不包含中文"); }else{ System.out.println("包含中文"); } } }
结果:包含中文
时间: 2024-11-03 21:59:58