The character encoding starts to irritate me.
It took me a while to get everything from the DB in the right encoding on the screen, but with help from the i18n helper, this worked out.
Now I only have one more problem: saving text...
If i add some letters with accents (eg é ç ...) in a text field and want to save it, already in my controller it show as some exotic combination of characters.
Could someone tell me why this is and how I can fix this.
Everything is in UTF-8 btw
Thanks!
//Edit:
When I save the form, this is my log output
Parameters: {"free_text"=>"test 1 2 é",
And everything is capable of UTF-8...
Can you illustrate your output?
Let me guess your situation.
Supposed that you log those characters in controller in log/development.log or production.log.
If you view that log in terminal, you should ensure your terminal is capable to show UTF-8, with appropriate font. Also, your shell is capable to show UTF-8 and so do your the text viewer.
Related
Note: I have been redirected to this website, as it believed to be the appropriate option for questions like this. If this is not the correct website, could someone please just let me know where I can find help?
I'm trying to write my program in Pycharm, but for some annoying reason whenever I try to type \, it shows up as ¥.
Here's a screenshot:
this is actually supposed to say print('\n'). Whatever has happened has changed all the \ to ¥ in all my files!
And, yes, I have tried copying and pasting the \ but it just ends up changing into ¥
So, could someone please let me know how to fix this??
This could be happening because you are using a font, particularly a Japanese don't. Change the font to an English font like Arial.
If that doesn't work you can use the Unicode backslash in Unicode and ASCII it is encoded at U+005C
I have one problem with charset, I need UTF-8 and ISO-8859-1.
I tried there to set up it:
(whmcs language )
but it is not working.
I tied this:
But it still show at homepage this:
Client area is working.
I just need this at homepage Ä Ö Ü ß *
I hope someone can help.
thanks
Did you try it without ISO-8859-1? After removing it you may need to re-type the strings again. UTF-8 should work, we use it with Arabic and it is perfect.
Check database and tables, they should be UTF-8 as well, and there are tools to convert tables to UTF-8. check this script:
https://gist.github.com/wesamly/2c994e6bd4466151b60b
Note: Backup your database before converting.
I have a local json file with some descriptions of an app and I have found a weird behaviour when parsing \u0092 and \u0091 characters.
When json file contains these characters, the corresponding parsed NSString is printed like "?" and in UIlabel it dissapears completely.
Example "L\u2019H\u00e9r." is showed as "LHér." instead of "L'Hér."
If I replace this characters with \u2019, then I can see the caracter ' in UILabel
Does anybody any clue about this?
EDIT: For the moment I will substitute both of them with character \u2019, it is also a ' and there is no problem confusing it with a control character. Thank you all!
This answer is a little speculative, but I hope it gets you on the right tracks.
Your best bet may be to give up and substitute \u0091 and \u0092 for something else as a preprocessing step before string display. These are control characters and are unprintable in most encodings. But:
If rest of the file is proper UTF, your json file probably has problems: encoding is wrong (CP-1250?) while you read the file as UTF, some error has been made when converting the file, or a similar issue. So another solution is of course fixing your file.
If you're not sure about how your file is encoded, it may simply be encoded in CP-1250 - so reading the file using NSWindowsCP1250StringEncoding might fix your problem.
BTW, if you hardcode a string #"\u0091", you'll get a compilation time error Universal character name refers to a control character. Yes, not even a warning, it's that much unprintable in Unicode ;)
I'm using Ruby 2.0 and Rails 3.2.14. My view is littered several UTF-8 characters, mainly currency symbols like บาท and د.إ etc. I noticed some
(ActionView::Template::Error) "incompatible character encodings: ASCII-8BIT and UTF-8
in our production code and promptly tried visiting the page url on my browser without any issues. On digging in, I realised the error was actually caused by BingBot and few spiders. So when I tried to curl the same url, I was able to reproduce the issue. So, if I try
curl http://localhost:3000/?x=✓
I get the error where UTF-8 symbols are used in the view code. I also realised that if use HTML encoded strings in place of the symbols, this does not occur. However, I prefer using the actual symbols.
And I have already tried setting Encoding.default_external = Encoding::UTF_8 in environment.rb adding #encoding: utf-8 magic comment to top of file and it does not help.
So, why does this error occur? What is the difference between hitting this url on browser and on CURL besides cookies? And how do I go about fixing this issue and allow BingBot to index our site? Thanks.
The culprit that was leaking non UTF-8 characters in my template was an innocuous meta tag for Facebook Open Graph
%meta{property: "og:url", content: request.url}
And when the request is non-standard, this causes the encoding issue. Changing it to
%meta{property: "og:url", content: request.url.force_encoding('UTF-8')}
made the trick.
That error message usually occurs when you try to concatenate strings with different character encodings.
Is your database set to use UTF-8 as well?
If not, you could have a problem when you try to insert the non-UTF8 values into your UTF-8 template.
In my rails app I work a lot with cyrillic characters. Thats no problem, I store them in the db, I can display it in html.
But I have a problem exporting them in a plain txt file. A string like "элиас" gets "—ç–ª–∏–∞—Å" if I let rails put in in a txt file and download it. Whats wrong here? What has to be done?
Regards,
Elias
Obviously, there's a problem with your encoding. Make sure you text is in Unicode before writing it to the text file. You may use something like this:
ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
your_unicode_text = ic.iconv(your_text + ' ')[0..-2]
Also, double check that your database encoding is UTF-8. Cyrillic characters can display fine in DB and in html with non-unicode encoding, e.g. KOI8-RU, but you're guaranteed to have problems with them elsewhere.