How should I write three dots?

ぃ、小莉子 提交于 2020-12-30 04:58:57

问题


Simple question: I want to set a TextView and in that I want to have three dots (Ellipsis). Like

Read more... <-- Now I'm sure I shouldn't just write ... into the String. How should I write these three dots?


回答1:


Write "\u2026" in your String literal. See http://www.fileformat.info/info/unicode/char/2026/index.htm




回答2:


You can use the UTF-8 character "Horizonal ellipsis" (U+2026), "\u2026":

http://www.fileformat.info/info/unicode/char/2026/index.htm




回答3:


I suggest to add this to your code:

interface CommonConstants {
    String ELLIPSIS = "\u2026";
}

You can now import that anywhere you need it. The name will make it easy to know what this odd Unicode string might mean.

Note that this is safe to use with any editor since the source only uses ASCII character to encode the information.

If you're sure that all parts of your build process (editor, compiler, ...) are UTF-8 safe and configured to use UTF-8 and you have the font, you can enter the Unicode using any of the usual methods of your OS (maybe Cut&Paste would be most simple).

note: Eclipse can handle UTF-8 but many people have configured it to use the default = platform encoding so they don't get what they expect.




回答4:


Now I'm sure I shouldn't just write ... into the String.

Why? Are you having some sort of issue with how text is handled by the application or operating system? What benefit is served by using a special Unicode symbol instead of a character built into every keyboard out there? You save a byte of data?

I can't imagine how I could be the first one to put this into an answer, but just use three dots.



来源:https://stackoverflow.com/questions/19997912/how-should-i-write-three-dots

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!