Is there a way to format the phone numbers? For e.g. +11234567890 to +1(123) 456-789. And also is it possible to separate ISD and STD codes in the phone number itself? Since apple is doing the same in IPhone's address book and as well as Mobile application, I believe that there is way to the same (but no idea how to do).
You want NSDataFormatter and probably NSNumberFormatter. Both are classes designed to handle just this type of problem with minimum fuss.
If you handle a lot of phone numbers you might want to go ahead and write a dedicated formatting subclass just for phone numbers. I used to have one that would return properly localized phone numbers e.g. formats for North America vs Europe vs Asia etc depending on the location set for the device.
Phone numbers are one of those common pieces of data whose handling grows surprisingly complex very quickly especially when you start throwing in international variations and various types of extensions like calling cards or voice tree controls.
Related
I'm in charge of technology at my local camera club, a not-for-profit charity in Malvern UK. We have a database-centric competition management system which is home-brewed by me in Delphi 6 and now we wish to add a scoring system to it. This entails attaching 5 x cheap-and-standard USB numeric keypads to a PC (using a USB hub) and being able to programmatically read the keystrokes from each keyboard as they are entered by the 5 judges. Of course, they will hit their keys in a completely parallel and asynchronous way, so I need to identify which key has been struck by which judge, so as to assemble the scores (i.e. possible multiple keystrokes each) they have entered individually.
From what I can gather, Windows grabs the attention of keyboard devices and looks after the characer strings they produce, simply squirting the chars into the normal keyboard queue (and I have confirmed that by experiment!). This won't do for my needs, as I really must collect the 5 sets of (possibly multiple) key-presses and allocate the received characters as 5 separate variables for the scoring system to manipulate thereafter.
Can anyone (a) suggest a method for doing this in Delphi and (b) offer some guide to the code that might be needed? Whilst I am pretty Delphi-aware, I have no experience of accessing USB devices, or capturing their data.
Any help or guidance would be most gratefully received!
Windows provides a Raw Input API, which can be used for this purpose. In the reference at the link provided, one of the advantages is listed as:
An application can distinguish the source of the input even if it is
from the same type of device. For example, two mouse devices.
While this is more work than regular Windows input messages, it is a lot easier than writing USB device drivers.
One example of its use (while not written in Delphi) demonstrates what it can do, and provides some information on using it:
Using Raw Input from C# to handle multiple keyboards.
Local travel cards in Saint-Petersburg, Russia have got huge id numbers that aren't easy to read and type into a web page when topping up the card online. So I want to build a small app that would take a photo of a travel card and parse the number out.
The task is a bit easier than a free form recognition:
card is of the very well known size
id numbers are of known size, are located in the very well known location on a card and they are number only, no letters (okay, there are two variations I think and maybe they will add 1-2 more in the future)
even the font is known in advance
even the first several numbers are the same for most of the card (so far there are only two prefixes used)
How would you do it? Are there any libraries tuned not for the general OCR, but for a "hinted" OCR like I need?
Best regards,
Artem.
P.S.
Actually a free/cheap web service for this task would also be good enough
Yes Google has a library called Tesseract and there is an iOS SDK on Github you can import into your application. So you can use this SDK and it has some documentation that you can read that will explain how to set it up in your app. It has methods that will return you a string with the text of the card in the string. BUT it will be ALL of the text from the card. So best thing to do would be to:
1 "clip" the original image to extract a sub image that displays only the portion of the card you wish to get the numbers from.
2 Process this sub image through Tesseract to retrieve the string you are looking for.
3 Then parse through the string and pick out the data that you need.
But just be warned, it can be a bit quirky. This SDK tends to recognize words best from images that are scanned, not "taken a picture of". Because although it is an advance piece of technology, it isn't perfect. So to get it to work as perfectly as possible for you, try to get scanned copies of the originals.
Best of luck.
The ideal solution for you would have three components:
1) Detection of the card. This is useful because if you have the detection, then the end users have much easier time actually using the scanner, because they can place the phone above the card in an arbitrary direction
2) Accurate OCR component. Ideally, customizable for this exact font you have on the card, for the exact position on the card.
3) Parsing mechanism. This would enable you to obtain the exact string written on the card without writing huge amount of OCR parsing code.
BlinkID SDK has all this. It has a preset for detection cards in the ID-1 format. It has integrated OCR engine. And it provides RegexParser, where you can define the exact format of the text which you're trying to extract from the document.
BlinkID was initially built for scanning ID documents which have very similar properties as the problem you're trying to solve.
Note. I'm one of the developers working on BlinkID.
I have a keyboard app designed for Serbian language. My keys have labels based in Serbian cyrillic alphabet. My xml strings that are used for those labels are enclosed in <xliff:g></xliff:g> tags, but a certain provider on a certain type of a phone still translates these into a different language. Just in case, I also have my strings in language specific folders, but it still happens. Does anyone know if there is a way I could disable translating of all my strings any other way?
There are providers who can handle technical files translations,i.e. know what to translate in technical files. Also, some are available for you to manage the translations. OneSky is one of these platform and we also provide translation service.
See GIF of how placeholder validation works in OneSky
Disclaimer: I work in OneSky
My app pulls phone numbers from the IOS address book and then stores them in core data. I've noticed that the IOS address book stores the data with formatting i.e. (650) 555 5555. This causes problems as when you try to send this to an url to call or text it doesn't work.
For other phone numbers entered manually in my app, I have been storing them without formatting and formatting them only on display.
Is there a preferred approach to storing character-free vs. with characters?
It's really up to you and the use you're going to give the numbers.
I've done this in the past and we chose to store phone numbers in with just plain numbers and display them with formatting according to the location since most likely all the contact numbers would be from a specific country or location. That was going to be easier for a person to look at.
Also we could just use the number stored without any modification to just call or send texts because that required the phone without formatting.
The parentheses, hyphens, spaces etc. are all part of the presentation of the data, not of the data itself. Therefore you should store them as pure numbers.
I have a game that relies very heavily on text-based communication, and therefore, I would like to only match players with other players who have the same language settings set, provided it is reasonable (i. e. one of the languages my app is localized for).
Now, when I get the preferred language, it is a string. The matchmaking object's player group, however, is an integer. What would be the best method to use integers for locales? Are they natively indexed in iOS, or do I have to provide my own indices?
Additionally, some people speak several languages. I can get the preferred languages from the system settings, but, as far as I understand, it's simply all the languages with varying order. Is there anyway for me to extract useful information as to which other languages besides the current one would actually be suitable for the user?
Game Center matchmaking is not flexible enough to handle your multi-language scenario. I'd suggest you make the user select one.
You will need to provide your own indexes for the languages you want to support.