Testing for Japanese/Chinese Characters in a string

后端 未结 6 619
我在风中等你
我在风中等你 2020-12-18 04:47

I have a program that reads a bunch of text and analyzes it. The text may be in any language, but I need to test for japanese and chinese specifically to analyze them a diff

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 05:28

    You probably can't do that reliably. Japanese uses a lot of the same characters as Chinese. I think the best you could do is to look at a block of text. If you see any uniquely Japanese characters, then you can assume the whole block is Japanese. If not, then it's probably Chinese.

    However, I'm just learning Chinese, so I'm not an expert.

提交回复
热议问题