Replacing Non-Breaking Space Android not working - android

I need to replace \u00A0, but it doesn't work with (found out which character it is by copying it to a text to unicode converter)
string.replace("\u00A0", " ");
It also doesn't work with copying the exakt character from the log into Android Studio. I unfortunately can't paste this character here, it gets converted to a normal white space.
I also tried many other solutions which should potentially remove this character, none of them actually worked.
My intention is to compare two phone numbers (looking like this: +49 176 34535...), one with non-breaking spaces and one with normal whitespaces from the keyboard. Non-breaking spaces result of reading the phone number from a notification.
Does someone have an idea how to solve my problem?

Related

Zero-width space with special characters

Interesting problem here, wondering if anyone has come across it.
I am building an Android app that has some special characters as text (mainly Japanese characters) and our designers want some soft returns strategically placed, incase the text needs to wrap due to width limitations on smaller devices.
The problem is that since the text is essentially Japanese, there are no spaces between words.
I know we can use \u200b as a zero-width space resulting in a string like this:
abcdef\u200bghijklmnop
appearing like this when there is enough room:
abcdefghijklmnop
and like this if it needs to wrap:
abcdef
ghijklmnop
The problem is that if instead of standard English characters, we use Japanese characters it doesn't seem to work. We don't get soft line breaks at all. It instead always breaks right where it runs out of space regardless of where we put the \u200b
ヘルプヘルプ\u200bヘルプヘルプ
results in:
ヘルプヘルプヘルプヘ
ルプ
Has anyone dealt with this before or have any ideas on how to solve this?

Stop punctuation marks from adding new lines android

I'm building an android app that generates random passwords. The passwords also contain symbols and punctuation marks for optimal variety. But Android always puts newlines after each puncuation mark because it interpreted the random characters as words. I've tried adding android:singleLine="true" but that just wraps text on one line instead of removing the newlines. Any ideas on how to fix this? This is a picture that shows what I mean:

Letter Spacing in EditText for Android

I am trying to have a custom EditText based on the background that i am using for. The Background image has some spaces between the entry areas so i need to have some space between the characters(kerning) to fit them right in. So for example after every character the user enters, i need to put 4 whitespace after that.
I couldn't find any solution for this on the net so far, some people suggested TextWatcher, but i couldn't manage to make it work as i want it too.
Can someone help me about it?
Thanks
I have you considered using a custom font? Some font types are made to stretch out or shrink or have empty spaces. With so many different fonts available online, you can definitely find something. You can also make your own with a software. It might be time consuming if you start the lettering from scratch. I'm not 100% sure if it'll fit exactly to your background, but it's idea that you can consider.
If it doesn't fit, I supposed you can always customized the background to fix your font too. Here's the code for those who might want to use custom fonts in their app too.
Typeface myfont = Typeface.createFromAsset(getAssets(),
"fonts/Blocks2.ttf");
myeditText.setTypeface(myfont);
The font is in the asset folder under another folder called fonts.
This question is related to How to change letter spacing in a Textview?
As shown at this issue: android format edittext to display spaces after every 4 characters a solution might be to insert spaces with Java code...
You need to use TextWatcher to achieve visual purpose spaces.
And use any simply split string by space logic to join it back or loop
through the entire string per character wise and eliminate (char) 32
from the string
As far as i know actual character spacing is not possible, though i'd love to use that myself as well.
Another option might be to use a custom font with the character spacing included.

how to revert back the newline character when content is copied from browser

I got to know that some older version of browser take new line character as single space.
Is there a method to revert back to that newline character when the content is copied?
any suggestion?
This is not possible when copying the rendered output; however if you can leverage the underlying markup you could obviously treat a newline as you desire before moving it to the clipboard.
You have to remember that the browser treats line breaks as white space characters and thus condenses the white space characters as it renders the markup.

Android. Problem with arabic keyboard

I make arabic virtual keyboard, and I have a problem.
If you write only arabic characters - all works (written right to left). But the numbers and punctuation marks are written to the right of the previous word. Although should be written to the left of the word. For example:
You write:
word_2011 where '_' is space
Must be:
'2011_drow' (look right to left, numbers read left to right)
but is:
'_drow2011'
Now more interesting. If you write 'NOW' you get
'_drow201WON1' (must be 'WON2011_drow')
This is Android problem? Or is it possible to solve it?
This is due to the way Android mis-implements bidi (bi-directional) logic.
You will also have issues with arabic letters not displaying the mid and start letters correctly.
To work around the space problem you could try to insert a direction character between them see: http://en.wikipedia.org/wiki/Unicode_control_characters. This will work, but will get a square displayed instead of a space in some phones.

Categories

Resources