Single character makes iOS crash - ios

Here's the situation, I'm using a custom font to render some special characters (icons) for an iOS app. I have used many of the characters in that font and everything is just fine BUT when I use one character (it doesn't matter where) the app crashes.
This problem ONLY occurs with that single character in that font, if I use any other character nothing bad occurs.
Any ideas?

Please be specific WHICH special character you are talking about & WHERE you are using it. Based on your given limited information, all I can think of is try using ASCII of that problematic character.

Related

Are there any keyboard character code differences between PC and Mac?

So I'm working on a site in PHP/JS and also a database. I have a co-worker that sends me documents written on Apple devices and I'm on a PC. Since I don't have access to a Mac, I'd like to know if spaces and punctuation are identical typed on different keyboards.
I want to be able to copy the contents of the documents and paste it in the database, however I don't want to assume that the PC dash character is the same as a Mac dash (that might be an actual minus character).. or that a PC space turns out to be a Mac narrow/en space.
I could just test a received document, but she works all over the place and never knows where she wrote what.
This is a programming question because I'm pasting mathematical expressions where such characters make a difference.. and also using PHP and JavaScript to interpret those characters.
The main issue is the character encoding in the document. Mostly likely that's a Unicode encoding (e.g. UTF-8) which is fully cross-platform.
Someone using a U.S. keyboard layout (and probably most others) intending to type something like dash/hyphen/minus would most likely produce HYPHEN-MINUS U+002D. There are, of course, ways of typing EN DASH U+2013, EM DASH U+2014, SMALL EM DASH U+FE58, HYPHEN U+2010, and others, but the user would have to do that deliberately. It wouldn't be done routinely just because they're using a Mac.
Also, some editors or word processors may do "smart substitutions", replacing the ASCII characters with fancier (more typographically correct) non-ASCII ones. That would be independent of Mac vs. PC. If it does that, the character would still come across to the PC as such, but if your use of the document data is sensitive to such differences (as is apparently the case), then that would be problematic.
It would be very unlikely that Space would routinely be anything other than a normal SPACE U+0020. There are, of course, ways of typing variants such as NO-BREAK SPACE U+00A0, EN SPACE U+2002, EM SPACE U+2003, etc., but the user would have to go out of their way to type those. And I doubt smart substitutions would replace normal spaces.

UITextChecker and non english words

I'm developing a custom keyboard for the iOS operating system and I'm trying to add the auto-suggestion feature. For English dictionary there seems to be no difficulties, but for languages like french I came into a problem regarding accents. See this example: The user tries to write "Chaîne" (chain). the UITextChecker retrieves words until user reaches the "î", after that the it stops, the word list is empty.
The code to retrieve the word list is as follow:
// While user is typing the txt variable is modified...
range = NSMakeRange(0, txt.length);
words = [m_textChecker completionsForPartialWordRange:range inString:txt language:#"fr_FR"];
This problem happens also using Italian and other languages that use accented letters. You do not retrieve "città" (city) while typing "cit..." or "citt..."
Maybe it is my fault in understanding the completionsForPartialWordRange:inString:language method real meaning.
I tried to choose other solutions, for example including an SQLite database importing the Aspell dictionaries, but I'm not sure if it is legal and it will be accepted by Apple review team. Moreover database originating from Aspell are quite big. To solve the latter issue I though to use an optional download feature from the containing app, but I can't figure out how its keyboard extension could access the app's `Documents' folder, because they do not share the same bundle path for that folder.
Can any one help me in understanding the UITextChecker and accented words?
Thank you very much...

Automatically transforming NSString into NSLocalizedString?

I am still paying dearly for learning iOS development, so please be kind.
I have an iOS application containing around 400 NSString litterals. I never thought that I would want to localize this app later on, so while being aware of NSLocalizedString I decided to not use them for my project. Now the world has changed and I need to localize this application. Is there any tool/script I can use that will run through my .m files and "search/replace" my NSStrings with NSLocalizedStrings before I extract them with genstrings?
Thanks
Roger
You made a mistake not writing your code correctly the first time, and now you have to pay the price.
You need to go through your program manually and change user-visible string literals to calls to NSLocalizedString.
Note that you do NOT want to globally change all string literals. Things like dictionary keys should not be localized.
Always, ALWAYS, use NSLocalizedString to create localized strings. It's only a few more characters to type, and it makes internationalizing your code DRAMATICALLY easier.
The good news is that the pain of doing this will serve as a bitter lesson and you likely won't make the same mistake again.
Yes! A find and replace regex will speed up this up.
In the find bar put:
(".*")
In the replace bar:
NSLocalizedString($1,comment:"")
This will change "normalString" to NSLocalizedString("normalString",comment:"")
So go through your code and on the ones you want to replace just press replace, this is a massive timesaver!
You generally don't want to replace ALL NSStrings with NSLocalizedString as not all strings are necessarily 'user facing'. You might have string constants that are used internally that the user never sees and these in general should not be translated. Hence, blindly replacing all NSStrings with NSLocalizedString is probably not a great idea.
There is a fair bit of work involved going through and doing this manually, but its a one-time effort - once you've done it once you'll know the correct way to handle any new user-facing strings and do it as you go. Having said that - there may very well be a tool out there somewhere that handles this elegantly, but there's no avoiding the manual picking which strings need to be translated and which don't.
From I have learned and checked out, there no automated method to turn your strings to localized one you wish. But there's a plugin for XCode called Lin, that makes your process easy.
When you are focusing on NSLocalizedString or other functions to get a localized version of a string, Lin shows the list of localizations that contains the inputted key string.
Lin
From the question and your comments it seems you have around 400 strings only 20 of which should not be localised. With that ratio, as you yourself say, changing them all and then undoing the change for 20 can make sense.
To do this get TextWrangler, or BBEdit, and perform a multi-file pattern matching search and replace. You can confine the search to files ending in .m or .h. The task will be quick and easy, apart from those 20...
HTH

Error encoding special characters

Bit of a strange problem (at least for me). In my Grails app I'm sending emails with some special characters (east European letters). Values of strings with special characters that I get from database are valid but the ones I create in application have "?".
Even more confusing is the fact that in development everything works fine, but when I deploy app to Tomcat instance I get the question marks.
I've set up everything to encode to UTF-8. At least I beleave so - obviously I'm missing something.
It sounds like you don't have the operating system language
packs installed for the languages you're trying to display.
While it appears as if the files themselves are saved properly, and the JVM
'understands' them because the character sets are supported, the GUIs
you're using can't display the corresponding encoding because the
underlying OS isn't displaying them.
I've experienced similar problems and the solution that
worked for me was to turn on the corresponding languages in the OS.

why can't I use secureTextEntry with a UTF-8 keyboard?

All,
I ran into this problem where for a UITextField that has secureTextEntry=YES, I cannot get any UTF-8 keyboards(Japanese, Arabic, etc.) to show, only non UTF-8 ones do(English, French, etc..). I did alot of searching on Google, on this site, and on Apple dev forums and see others with the same problem, but short of implementing my own UITextField, nobody seems to have a reasonable solution or an answer as to whether this is a bug or intended behavior.
And if this is intended behavior, why? Is there a standard, a white paper, SOMETHING someplace that I can look at and then point to when I go to my Product Manager and say we cannot support UTF-8 passwords?
THanks,
I was unable to find anything in Apple's documentation to explain why this should be the case, but after creating a test project it does indeed appear to be so. At a guess, I imagine secure text entry is disallowed for any language using composite characters because it would make character input difficult.
For instance, for Japanese input, should each kana character be hidden after it is typed? Or just kanji characters? If the latter, the length of time characters remain onscreen is long enough make secure input almost moot. Similarly for other languages using composite input methods.
This post includes code for manually implementing your own secure input behaviour.

Resources