Incompatible character encodings: ASCII-8BIT and US-ASCII and Image format allowing just PNG

510 views
Skip to first unread message

Glauco Custódio

unread,
Feb 16, 2013, 7:40:22 AM2/16/13
to serve...@googlegroups.com
Hi, I have used Serve and I am trying to add this character: á in one of my views, it has accent, but I get this error message:

Encoding::CompatibilityError at /welcome

incompatible character encodings: ASCII-8BIT and US-ASCII


I have tried add utf encode (# encoding: UTF-8) but I dont know where I must place it, can anyone help?

Another thing.. When I use <%=image 'imagename' %> Serve automatically look for "imagename.PNG", if I need to use JPG or other format? I cant?

Thank you.

Jess Brown

unread,
Feb 16, 2013, 11:15:12 AM2/16/13
to serve...@googlegroups.com
Hi Glauco,

I recently had a rails project where I needed the same thing.  My text was in a helper module, but I added

# encoding: UTF-8

to the top of the file and it worked. 

You would need to add a 

<%# encoding: UTF-8 %>
 
 to the top of your view file.  If you use it in multiple views, you might can try adding it to your _layout file (I haven't tried this part, but I confirmed that the line in the view file works).  Interesting note, for others reading this: if you're using haml views, this isn't necessary.  They must handle the encodings.

As for the images, I actually wasn't aware of the image helper.  I use the image_tag helper (same as in rails) there you can pass the format <%= image_tag("/images/image_name.jpg") %>  Unfortunately you do have to pass the /images directory in the pathname.  

Hope that helps, let me know if you run into any issues.

Jess


Jess Brown
Brown Web Design


--
--
Serve Users Group
Mailing List: http://groups.google.com/group/serve-users/
Project: http://github.com/jlong/serve/
 
---
You received this message because you are subscribed to the Google Groups "Serve Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to serve-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages