Matching patterns with Chinese characters (encoded in UTF-8) in Java

I need to check if the Chinese province is in the address in Chinese.

I can read and write Chinese characters easily.

I tried using the indexOf () method for String to check if the province (e.g. 广东) is contained in the address (δΈ­ε›½ 广东). However, this always returns -1.

When I try to check the numbers (e.g. whether 103 is contained in 9910399), it works fine.

Do I need to do something else to handle UTF-8 string matching? Thank you Matt

+5
source share
1 answer

, . indexOf() .

, (*.java). , eclipse, Window/Preferences/General/Workspace/Text file Encoding. UTF-8.

-, , java-. . , javac , , -encoding. , , .

.

+2

All Articles