How to print tilde characters correctly with PDFKit? - ruby-on-rails

When converting HTML to a PDF document characters such as é or ñ are printed as question marks. How can I display them correctly in the PDF document?

Make sure you are setting the encoding on your HTML to UTF-8. It is probably trying to interpret it as US-ASCII
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

Related

Pound symbol display

I have an mvc solution with a standard view using _Layout page for layout. Layout page has charset=utf-8 set in the header like so:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
For some reason, when I type "£" symbol in the view I get it displayed as "A£", with a dash above "A". At the same time when I put the same symbol in the _Layout page it's displaying fine. I got this resolved by using encoded value
£
but was wondering why does it happen?
It may have happened because of a mismatch between <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> and the encoding of your physical file.
E.g. Your file could be saved as ISO-8859-1.
I have read that note. I am using Adobe Dreamweaver for all my files and I think it is encoded in 'utf-8'.

Grails: russian characters from form

Russian characters are shown correctly on the page but incorrectly displayed on the server side if send them from form. For example word игра transforms into игÑа. I have following lines in Config.groovy:
grails.views.gsp.encoding = "UTF-8"
grails.converters.encoding = "UTF-8"
And following line in the main layout view:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
What should i do to fix it?
The data “игÑа” results from UTF-8 encoded “игра” when misinterpreted as ISO-8859-1. It sounds like the HTTP headers specify ISO-8859-1 (or some similar 8-bit encoding); this overrides any meta tags.

Character encoding issues for Russian Chars

# http://tinyurl.com/7v67lnh I am working on a new page for a client. The character encoding I am using is utf 8:<?xml version="1.0" encoding="UTF-8"?> Also added a unicode BOM signature
. But somehow the Russian code in the right sidebar is mangled. Any ideas why?
use UTF-8 for your html page too, add this tag to your html code <meta http-equiv="content-type" content="text/html; charset=UTF-8"> upon your title tag
As mentioned in the comment to my question:
Solved it all by adding AddDefaultCharset UTF-8 to the .htaccess.
Apparently the server was going for another character encoding such as
Cyrillic or Windows. –

C# MVC Textbox MultiLanguage

I have a view with a TextBox for input. However it seems like it doesn't support all Spanish characters. The upside down question mark doesn't seem to work. Is there a simple way to get around this?
<%= Html.TextBoxFor(m => m.Product.Name, new { style = "width:400px", maxlength = 150 })%>
Things to check:
Inside your web.config you are using utf-8:
<globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
Inside the <head> section of your site you have a <meta> tag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Your view files are utf-8 encoded with BOM on the disk

Grails interprets and closes HTML meta tag

In my Grails GSP file I'm using the HTML meta tag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
The problem is that Grails closes this tag and renders it as:
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
This fails W3C's HTML validation (since my doctype is HTML and not XHTML).
Is there a fix for this? How can I get Grails to not interpret the
meta tag?
I'm using grails-1.2-M4.
Follow up:
I create the Grails bug GRAILS-5696 for this issue.
Not sure that this is the most beautiful solution, but at least it will work for your case:
<%= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' %>
Well...this does not work since it is preprocessed by Grails before displayed as is.
So the only solution I see is to create a TagLib and output the content like this:
class MetaTagLib {
static namespace = 'my'
def meta = {
out << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>"
}
}
and use it like:
<my:meta />
It works. Tested.
You could validate as HTML5 instead of HTML 4.01, by using <!DOCTYPE html> (that's it, really!). HTML5 allows trailing slashes even in the HTML syntax, in order to allow for systems like this that produce pseudo-XHTML.
Of course, HTML5 is not yet a finished standard; it may change. I think that this aspect of it is unlikely to be changed, but there is still some fairly contentious debate about a lot of the new HTML5 features, so keep in mind that it's not yet finalized.

Resources