strange UTF-8 byte encoding issue with Rails, IE, PostgreSQL, delayed_job - ruby-on-rails

I'm seeing a relatively strange (and hard to diagnose) error with a combination of IE8, Rails 3.0.3, PostgreSQL and delayed_job.
I have a text area on one of my pages, and in the controller I delay a message with delayed_job which includes an object which has the content from the text area:
SomeMailer.delay.send_message(message)
This works fine on Chrome, FF, Safari. However in IE8 only, and only when I actually enter text in the text area, and it looks like only when I enter a carriage return in the text area (I think), I get this error from the controller:
invalid byte sequence in UTF-8
This appears to me to be when delayed_job is serializing the job to the database via ActiveRecord, that it doesn't like the character encoding in the newline (\r\n). It's a bit hard to figure out because I don't know if this is an IE, Rails, delayed_job or Postgres issue.
Side Note: I'm getting this error locally, but it doesn't appear that this error appears on Heroku - so maybe they have their database configured better than I do?
Environment:
Rails 3.0.3
Ruby 1.9.2
Postgres 8.4 - encoding UTF8, collation en_US.UTF-8
delayed_job 2.1.4
IE 8
Any thoughts would be appreciated.

Are you setting your encoding in the HTML that is being sent to IE8? e.g.:
<!doctype html>
<head>
<meta charset="utf-8">
</head>
It's possible that the other browsers are working around the missing information and assuming UTF-8 when encoding the data from your text area.

Related

Rails <script> tag in <head> having random string in "type" attribute and therefore not loading JS

In my Ruby on Rails website, script tags in head get assigned random string in type attribute. It only happens on a single page though. All other pages are fine and the correct type="text/javascript" is used. Therefore, on that page scripts aren't being loaded and I have to fix it.
It only happens in production.
Noticed that all scripts have exactly the same string prepended before text/javascript and it changes on each reload.
Absolutely have no idea where to even start. Maybe you could help out?

Unwanted characters in cached pages - Rails 5

I'm exploring the Rails caching in order to speedup the page loading of a website that is becoming very big passing the time.
Said this i'am done the simple steps to enable caching on my pages and it works very well.
Using caches_page :page_name
I have only one issue - I find a lot of unwanted characters in my page, it is regarding letters like "à" or " ' ", " ° ".
E.g. : instead of "'" i got "’"
this is related both for text inside the database and static text in the page.
What should be the cause of this wrong font rendering?
My fonts are included in the fonts directory and work very well in the non cached pages - they are google fonts (Roboto and RobotoCondensed).
I'm using heroku for production and I don't know if I have to change some production environment configuration to manage this.
I got no errors in console and no other messages.
SOLVED!
there was a missing line in my of the html layout file:
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
this set the correct character encode on all the pages

After updating rails 2.3.2 to 2.3.15 destroys scandic charset

We have problem with scandic charset.
We have localization file as *.yml and database which contains also some localization.
Problem is that when we use Actionview helper it destroys scandic charset by removing characters from the string.
If we use normal html tags like span or p then it works just fine.
Any ideas why the problem is only with helpers?

rails : heroku error logs

Okau, I have a rails app which works fine on my localhost. Now I have a new problem on the logs which seems to have an issue with the syntax. I have javascript include tags as below :
Okay This is the main error
ActionView::Template::Error (/app/app/assets/javascripts/jq_scroll/jq_animate.js has a invalid UTF-8 byte sequence):
How do I resolve this?
Are you interpolating any I18n string into the JS file or does it contain any non-ASCII characters? If so, try adding a "magic comment" at the top of the file (assuming the file has the extension .js.erb):
<% # coding: utf-8 %>
// JS file content...

character set encoding issue with multi-language featured site

I am here suffering from a simple, common problem.
my site is multi-language featured, built in codeigniter framework.
for eg for a french language here i have used
$lang['login'] = 'ConnÈcter';
this then appeared as Conn�cter in the view.
then i solved this by adding
<meta charset="ISO-8859-1">
which then resolved the issue.
but when the contents is loaded with characters like
Sáenz-Mata & Jiménez-Bremont
then is is changed to
Sáenz-Mata & Jiménez-Bremont
note é is changed to é even when i use
<meta charset="ISO-8859-1">
when above meta is removed, it gives me Conn�cter when the language is converted to french.
so please suggest me something which can handle both situations.
hope somebody understands it.(got messed up describing.)
thanks.
use <meta charset="utf-8">
Use UTF-8 consistently for all pages, as explained in the CodeIgniter User guide. Make sure the encoding of each file matches its declared encoding. What you are experiencing now is caused by mixing encodings (UTF-8 and ISO-8859-1 mostly).

Resources