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?
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?
Write "\u2026" in your String literal. See http://www.fileformat.info/info/unicode/char/2026/index.htm
You can use the UTF-8 character "Horizonal ellipsis" (U+2026), "\u2026":
…
\u
in a String literal. –
Semifinalist 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.
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.
© 2022 - 2024 — McMap. All rights reserved.