Using accents in forms

7 replies [Last post]
frostmar
Offline
Last seen: 6 years 29 weeks ago
Joined: 2011-06-11

I want to create a form in Spanish in Drupal 7. However, whenever I include accents, the #title does not work. For example:

title => t('¿En qué ciudad vive?),

does not print any title at all.

Can someone help please?

Martin.

obrignoni
Offline
Last seen: 10 years 10 weeks ago
Joined: 2011-02-28
Saludos

Nice to see someone write spanish in this forum, jeje. I came across this same problem. Make sure that you save your files as UTF-8.

- Suerte

frostmar
Offline
Last seen: 6 years 29 weeks ago
Joined: 2011-06-11
Thank you.

Gracias por tu ayuda. I guess I had better carry on in English or I'll break some forum rule ;)

I'm not quite sure what you mean by saving them in UTF-8. I'm currently developing in a Windows 7 environment with a view to uploading it on a Debian server. I have found that wrapping the text in htmltentities() does the trick!

I think this is really a PHP issue rather than a Drupal one.

Any further comments?

Martin.

obrignoni
Offline
Last seen: 10 years 10 weeks ago
Joined: 2011-02-28
UTF-8 is one of many

You are right, it might be more of a PHP and file encoding issue...

UTF-8 is one of many character encoding formats that affect how characters are displayed... Depending on which PHP editor you use, it saves files with a default encoding. You should make sure that your editor is saving your files as UTF-8 which supports spanish accents.

For example, i work on Komodo IDE and it allows me to change and save the file with a different encoding if i need to.

If you do this, there won't be a need for you to use htmltentities() as it might give you some problems when you deal with html markup. Best not to depend on that function...

Which editor are you using for PHP?

frostmar
Offline
Last seen: 6 years 29 weeks ago
Joined: 2011-06-11
Komodo

I too am using Komodo but I am not sure how to change the encoding. I've gone into Preferences - Internationalization and changed from CP1252 to UTF-8 but it appears to have had no effect.

Any ideas?

obrignoni
Offline
Last seen: 10 years 10 weeks ago
Joined: 2011-02-28
I have Komodo IDE for Mac.

I have Komodo IDE for Mac. Assuming that the UI is the same in Windows...

At the very bottom of the interface you have the grey status bar, which has some select menus to the right. On one of them you'll see the current encoding allowing you to change it by clicking and selecting UTF-8 from the encoding options and saving the file again.

Let me know if you find it...

frostmar
Offline
Last seen: 6 years 29 weeks ago
Joined: 2011-06-11
Komodo for Windows

Komodo IDE for windows is just as you describe Komodo IDE for Mac. I changed the encoding to UTF-8 and it works perfectly. Now I need to do some reading about encodings so I am up-to-speed. Thank you very much!

I'm sure I'm not meant to ask this in the forum but what is your interest in Spanish? If you want to take this off-line I can be contacted at martin_frost arroba usermail.com.

Thanks again!

obrignoni
Offline
Last seen: 10 years 10 weeks ago
Joined: 2011-02-28
Oh, I'm glad that it worked.

Oh, I'm glad that it worked. As for my interest in Spanish. It's my main language as I am from Puerto Rico. But you are right, we shouldn't talk about that in this forum. If you want, you can follow me on twitter as @obrignoni and i'll follow you back...

Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:


Loading...
Contact us

Below are the supported keyboard shortcuts for our video player.

space
Start / stop video
shift
Go to next video
shift
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
1...9
Jump to a percentage (2 is 20%, for example)
f
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
$29
1 month
$156
6 months
10% off
$276
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
user
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.