how to make (,) to (.) for decimal button when using uikeyboardTpeDecimalPad - iphone

I use UIKeyboardTypeDecimalPad for keyboardType. When I test in mac, I see button decimal in (.), but when I test in iPod, decimal button become (,). How can I fix this ?
This is the code I tested:
self.rielPayTextField.keyboardType = UIKeyboardTypeDecimalPad;

I guess it is a setting related to the 'Region Format' specified on your device.
You can double check your settings going in 'Settings', 'General' and finally choosing 'International'

The thread may be a little older, but here's what I experienced:
The "." and "," depend on your regional setting of your iDevice.
I'm in Germany, so the decimal separator is "," and it showed on the numberpad.
When switching the region and language settings (my app is 4-lingual) to english, I had the "." decimal separator.
So your numberpad should be fine, as long as you work with decimals.
Only thing you have to care about is to check the number that was entered by the user. You have to make sure to use nslocalized number so that the input gets properly converted to be handled by your app. A double uses "." as separator, so entering a decimal of 3,4 in German would result in errors as the colon is not recognized as decimal separator.
I hope this helps.

Related

How to combine two characters into one character?

I am building a text editor app. I want to implement numbers & bullets like apple's notes app. For numbers I am using "1." (number + full stop). Now the problem is when I try to remove "1." using backspace, I will have to press backspace twice because "1." treated as two characters. This problem becomes worse when my list reaches "10." or "100.".
I have been looking into unicode characters. There are unicodes for "1." (\u{2488}), "2." (\u{2489}), but these are upto "20." (\u{249B}) only. I could not find more than that anywhere.
Can you give me a solution or a different approach to solve my problem ?
Thank You !

How to display and read a float in a non english (german) ionic 3 app?

In an ionic 3 app I am currently trying to get a floating point number as user input. Since the application is exclusively targeting a german audience I am expecting input with a comma as the decimal separator, e.g. 750,5.
In addition I would like to open the numerical keyboard.
I tried including an input field with type="text". I parsed the resulting input string using a custom parsing method, which respects the different decimal separator.
Since the input field has a two way binding and the application might change the number itself I convert the number to a string using the Angular decimal pipe like so:
numberString = new DecimalPipe('de').transform(value.count, '1.0-2');
That worked well, however the app always opens the full alphanumerical keyboard.
To show the numerical keyboard I used the input field with type="number".
<ion-input type="number" step="any"></ion-input>
Using this, the numerical shows as expected. However the input field now includes thousand separators. For example if I type 7500, the input field displays 7,500 using the English decimal separator.
Now I am not sure where this problem is caused but the app itself seems to be running under an English locale although the device is set to German. I expect the problem to be solved by setting the web view locale to German. How could I achieve this?

How is spanish accented character displayed for spanish keyboard?

I have an English keyboard. With little setting on keyboard preferences on my window machine I am able to type Spanish character.
To type á I have to press two keys.
' + a = á
But when I change to normal English layout I get
' + a = 'a
How is switching between different keyboard/layout gives different result? As per my understandng in both the cases it passes the same keycode but the end results are different.
It should not give the same result, since they are different symbols.
"Spanish" accent, aso known as "acute accent" has its own utf-8 code and it is used to change the sound-values of the letters to which they are added.
The other symbols is an apostrophe, whose use is quite different to previous one.
That's because I believe there are some reasons to think that they are not using the same keycode but it's using a different keys configuration.
Take a look at this UTF-8 table:
https://www.utf8-chartable.de/unicode-utf8-table.pl
Accent: U+00B4
Apostrophe: U+0027
Please, review your keyboard to ensure it is correctly configured to differentiate both symbols.
In my case, with spanish keyboard configuration, I'm able to display both as follows:
Soy Rubén (spanish example)
I'm Rubén (english translation)

Trouble using new NSNumbeFormatter

I have an app which read an import in a TextField then process it using
let number = NSNumberFormatter().numberFromString(numberString)
if let number = number {
let floatValue = Float(number)
}
While I'm working with regional formats which use comma as decimal separator (like Italy or Germany) everything works (I can write 17,80 or 17.80 and they work both). When I work with regional formats which use dot as decimal separator (like USA), when I use dot as decimal separator (17.80) OK but if I use comma (17,80) app crash!
How can I solve it?
Would looking at the string and changing it to whichever format you know (e.g. making it always use a decimal separator) won't cause problems be a viable fix here?

preg_replace to include decimal point

I have currency values within a table and for filtering I want to show only the numbers without currency symbols, but, I need the decimal point, here's what i'm using
$price_check = preg_replace('/\D/', '', str_replace(',','',(str_replace('£','',$item[item_price])));
How do I keep the decimal point? is first question
Also, I'm removing £ first (ascii for GBP) and then removing comma (if present) - is there a better way to do this?
Figured it out, the preg_replace anyway
$price_check = preg_replace('/(\.[0-9]+?)0*$/', '$1', str_replace(',','',(str_replace('£','',$item[item_price]))));