I have a messaging application and I have problems sending push notifications to ios with emoji text.
The following code for push works ( i tested it b writing manually in my php code and sent also manually to apple, received the message fine):
"alert":"hi \ud83d\ude04".
But the code for push which comes from the device look like this: "alert":"hi \Ud83d\Ude04" ( \U instead of \u ). Messages with \U in text simply are not delivered!
The question is: is there a difference for apns between upper and lower literal in this case? If so, what is the best way to fix this problem? By that i mean shall i replace characters on the client or on the server.
Thanks in advance.
Use emojis with unicode 6.0 instead
Wikipedia entry: http://en.wikipedia.org/wiki/Emoji
Related
I am trying to intercept and replace emoji with a corresponding text. I left the default encoding on the Web API (UTF-8 / UTF-16 respectively).
How can I convert an emoji like 😉 to something like U+1F609?
Here is something that helped me out, although it is in Perl. But you can encode and decode. This should be what you're looking for: https://metacpan.org/pod/Encode::JP::Emoji
This is quite an old post and even though I'm not on the project anymore I want to still answer with my findings for future reference if someone else has the same problem.
What I ended up doing is to create a dictionary with key the UTF combination of the emoji and as a value the text. One thing as an advice: I made sure the longest UTF combination, some emoji have 4 or even 5, as the first ones as otherwise some emoji never got reached. Totally not a perfect and future proof solution that I was hoping for but it worked for us and it shipped into production where it has been working since 2017.
I sometimes see error messages in the log file of my iOS device with at least part of the text containing dashes between each letter, like this:
... ’-t -b-e -c-o-m-p-l-e-t-e-d-. -(-k-C-F-E-r-r-o-r-D-o-m-a-i-n-C-F-N-e-t-w-o-r-k -e-r-r-o-r -2-.-)-" -U-s-e-r-I-n-f-o-=-0-x-1-4-5-f-d-0 -{-k-C-F-G-e-t-A-d-d-r-I-n-f-o-F-a-i-l-u-r-e-K-e-y-=-8-}
I'm just curious as to any meaning this might have (certainly doesn't do much for readability, but I suppose it's easy to spot), or if it's just a random problem. (My device is jailbroken, if that makes a difference).
Update: I was able to format a log message similarly by calling NSLog with a non-ASCII character at the beginning:
NSLog(#"€ Line will be formatted strangely");
I suspect that the message was in UTF16 (or some other double-byte character set) and was incorrectly mapped in as ASCII when converting to an NSString.
This
is the link I learned to send multi-part SMS in PDU, a very good tutorial.But how if I want to send Unicode SMS? From one of the comment from the developer:
Yes, the DCS should be 0×08 and the UDL should be in octets (which ends up being 1 + UDHL + 2 * number of characters). Also you don’t have to insert padding as in the GSM-7 case. I know you’ve already managed to send UCS-2 (not concatenated) messages, so it must be something small you’re missing. If you wish you can post your PDUs so I can check…
Jeroen
it seems I do not need to add 1 bit padding for the message. But if I using the same UDH format as normal SMS it will just show me unknown characters.
Can anyone give me some hints?
This is the sample PDU with chinese character but should be with errors..
0041000B910661345542F60000A00500030302010008044F60597D
Thanks.
Your DCS is wrong.
0041000B910661345542F6000*0*A00500030302010008044F60597D
should be
0041000B910661345542F6000*8*A00500030302010008044F60597D
for a DCS of 0x08 = UCS-2 encoding.
sadly, after iOS5 finally released, I got report from my users that they can not login.
Because there is emoji symbol in there names, and apple changed the encoding of emoji.
so there username contains a old version of emoji, how could I convert them to the new encoding?
thanks!
be specific: one emoji symbol "tiger", it is "\U0001f42f" in iOS5, but "\ue050" in earlier iOS version.
iOS 5 and OS X 10.7 (Lion) use the Unicode 6.0 standard ‘unified’ code points for emoji.
iOS 4 on SoftBank iPhones used a set of unofficial code points in the Unicode Private Use Area, and so aren't compatible with any other systems. To convert from this format to proper Unicode 6.0 characters, you'll need to run a big lookup table from Softbank code to Unified over all your current data and all new form data as it gets submitted. You might also want to do Unicode normalisation at this point, so that eg. fullwidth letters match normal ASCII letters.
See for example this table from a library that does emoji conversion tasks for PHP.
Emoji in usernames though?
I had the same problem, after digging for hours and finally found this answer that works for me
If you are using rails as your server, this is all you need to do. No need to do anything in ios/xcode, just pass the NSString without doing any UTF8/16 encoding stuff to the server.
Postegre stores the code correctly, it's just when you send the json response back to your ios client, assuming you do render json:#message, the json encoding has problem.
you could test whether you are having json encoding problem in your rails console by doing as simple test in your console
test = {"smiley"=>"u{1f604}"}
test.to_json
if it prints out "{\"smiley\":\"\uf604\"}" (notice the 1 is lost), then you have this problem. and the patch from the link will fix it.
I need a representation of µ or "micro". That funny small u with the long tail on the left side. Maybe you can see it here: µ
Some weeks ago I was reading in the docs, that it's a bad idea to type any special characters into the source code. So to prevent problems, could I encode that special character µ somehow like web folks do with , in an NSString? And if so, is there an overview of these codes or a way to get the correct code?
Take a look at this thread:
How do I escape a Unicode character in my Objective-C source code?
NSString *stuff = #"The Greek letter Beta looks like this: \u03b2"
For the iPhone, and for Mac OS X using the Xcode 3.x tool chain (targeting 10.2 or later, which you must be if you're using Xcode 3.x), it is safe and supported to use a literal µ in the string constant. The only caveat is that you must set the -finput-charset command-line option if your source files are not UTF-8 or UTF-16.