我有大约 48 个特殊符号,想将它们存储在一个字符串变量中。是否有可能做到这一点?如果是,请向我提供解决方案。我正在使用 NetBeans IDE。
♥ ♡ ❤ ♤ ♢ ♦ ♡ ♡ ❣ ❦ ❧ ☺ ✔ > ⌂ □ ☼ ✯ ✰ ◕ ◔ ♮ ♯ ❝ ❞ Δ ☾✽ ✾ ✿ ❁
❃ ❋ ❀ ∞ → •♥• ¤ ø „ ★ • * + Ω = ◊ ≥ ‡ › … ¤
上面是我要存储的特殊符号,试了一下,
public String symbols = "? ? ? ? ? ? ? ? ? ? ? ? ? ? > ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? •?• ¤ ø „ ? • * + ? = ? ? ‡ › … ¤";
这是我的代码:
StringBuilder tweetText = new StringBuilder();
if(count_symbol > 50)
{
count_symbol = 0;
}
String symbol_array[] = symbols.split(" ");
tweetText.append(symbol_array[count_symbol]);
tweetText.append(" ");
count_symbol++;
请提供一些解决方案。
最佳答案
I think you didn't set the
character encoding
in project properties toUTF-8
that's why special symbols are converted to question marks.
关于java - 我可以在 String 变量中存储特殊符号吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21037104/