Unicode characters in Grails - grails

I am trying to create an application in grails, its much like a blogging application. One of the requirement is that the application must support unicode, the user must be able to enter the blog using unicode character. I have changed the database to 'utf8_unicode_ci' and when i directly enter a unicode record to database, the text is displayed in unicode. The problem is when I enter the unicode characters from application, all I get is '?????' characters. How can I modify the application so that it supports unicode characters ?

Probably you didn't setup your database url correctly. Similar question here.
jdbc:mysql:///dbname?useUnicode=true&characterEncoding=utf-8

Related

Emojis in domain names - strange behaviour in iOS chrome

I was fooling around on my phone and decided to try putting an emoji in the url bar of google chrome. I entered in 😀.com, the emoji which is equivalent to unicode U+1F600. Chrome ended up evaluating that as http://xn--e28h.com/, which took me to a "webpage unavailable" screen (ERR_NAME_NOT_RESOLVED). I looked up xn--e28h on godaddy and it was unavailable.
Here are my questions:
Why did 😀 turn into xn--e28h? I don't see any relation with the unicode.
Why are domains of this format unavailable on godaddy?
Bonus question: why can't we put emojis in domain names?
DNS uses a special way to encode Unicode into ASCII. The xn-- prefix says that it's an encoded name, and since the whole name in this case is one Unicode codepoint the rest just looks incomprehensible. You can start reading more about this here.
Most (if not all) top-level domains have rules on which Unicode characters they allow for names in that TLD. For example, .SE only allows those characters that are used in one of the official languages of Sweden. This is entirely a policy thing, so the "why" gets fuzzy.
See 2.

Rails, Unable to store Foreign accented words in PSQL DB with utf-8 encoding

This is my first time running into such issue so if m not thorough enough I apologize for that.The project I have requires me to store data in French language, initially the encoding was set to utf-8 in database.yml however when I try and change that to latin 1 I get an error saying:
PG::InvalidParameterValue: ERROR: encoding "LATIN1" does not match locale "en_US.UTF-8"
The data that is stored in the utf-8 encoded database is in the form of broken special characters and not in the form of the actual foreign accented letters, I have googled a lot but have found solutions like recreating the template1 database with new encoding.
I want to ask the following points:
How will recreating template1 database effect my existing databases on that template with utf-8 encoding (in case I want to retain all those as well).
Is there a way to create an additional template databases (apart from template0, template1) as I dont want to lose the existing en_US.utf-8 databases on that template.
Also is this the right approach or is there any other way this can be achieved. I have been stuck on this issue for quite a while now.
Any sort of help will be hugely appreciated. Thanks a lot.
Also I would like to know if by any way can we specify encoding/charset for a specific schema inside db template1.
Per comment discussion it sounds like your DB is in UTF-8, i.e. SHOW server_encoding or SELECT current_setting('server_encoding') returns utf-8.
If so, you should leave your encoding in database.yml as utf-8 (or unspecified which should I think mean that it uses the server encoding).
Then you should use UTF-8 throughout your application. Run your application in a UTF-8 locale to ensure your collations are correct.
When dealing with web browers that request non-UTF-8 encodings, you can and should decode their responses into UTF-8, and when you're sending data to the browser, you should transform it from UTF-8 into the browser's requested encoding. The browser tells you what encoding it wants in its HTTP headers.
Most (all?) browsers support UTF-8, though, so instead you can tell the browser to decode your pages as UTF-8 and to send all GET/POST requests to you in UTF-8 too, using headers like Accept-Charset and the charset option of Content-Type, e.g. Content-Type: text/html; charset=UTF-8. This is what I suggest doing.
I don't know the specifics of how Rails does encodings/charsets, as I work on the database side, but that should get you started. This answer is about a pretty old Rails version, but mentions setting config.encoding in config/application.rb. You'll also need to make sure your Ruby files are marked as UTF-8 with #encoding: utf-8 if they actually incorporate text outside the 7-bit ASCII range.
Try to avoid setting HTTP headers directly and doing direct encoding/decoding. The framework should have a way to do that for you. Find it and use it. Then use utf-8 throughout the application and database.

I can see Urdu language in DB but not on on home page

I have Urdu language not-for-profit news website. I had old database in MySQL4.0 but now the server has updated the database and it is now MySQL5.0.
My website was working well in earlier database but now text shows as question marks. But I can see the news with Urdu text in phpMyAdmin.
Can somebody tell me what is problem?
Thanks,
Kazmi
I assume you have your character sets set to utf-8 which I believe should work for urdu.
you may need to call this mysql statement before any query:
SET NAMES 'UTF-8'
more information about it at
http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html

Missing characters Special characters in e-mail when using extended mail umbraco

I have a problem with German characters when using the type "Send email, extened".
i recieve mail the character set is all messed up.
Example :
Müler ==> M??ler
help
I believe this is a character set encoding issue with the way that the email is being encoded. The default encoding for emails in ASP.Net is us-ascii which will be missing the extra characters. Report the issue to the Contour guys at the Umbraco Issues tracker and they should fix it. If you're in a hurry, just write your own send email workflow, ensuring that the email uses the correct encoding for the character set that you are using (such as UTF8). For information on how to create your own workflows, refer to the Contour developers guide, which has an example. You can see the source code of most of the built in Workflows here

Proper handling of foursquare venues unicode characters in iOS app

What's the proper way to handle unicode characters in an iOS app that calls the foursquare API?
Our current setup calls the foursquare API from our iOS app, and returns XML (yes, we're changing this to JSON).
While testing our app, we discovered the hard way that this foursquare location borked our app -- apparently because we did not setup to handle the two Emoji characters in the venue name.
What's the proper way to handle unicode characters at each level?
In Objective-C, as we call the foursquare API?
In our our WCF web services, as we return XML data to the app?
In SQL Server 2008, as we store a place name that may contain unicode characters?
On the database side, I know that we need to make some changes to the Collation settings, among other things.
What changes, if any, are needed to support unicode 6.1 correctly in our iOS app and web services?
Thanks!
I'm guessing you are trying to convert a unicode string to another encoding then back to unicode. If the converter doesn't know what the unicode character is then it could do something strange(e.g. the converter might convert one of the new sad pussycat emoji characters to a square root sign).
This might happen without you explicitly doing it depending on how you have your database setup, the XML encoding you use, your HTTP server configuration, etc.
Unicode 6.1 just adds characters, the encoding is exactly the same(i.e. some codes that didn't map to anything now map to things).

Resources