LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-26-2010, 01:43 PM   #1
mattca
Member
 
Registered: Jan 2009
Distribution: Slackware 14.1
Posts: 333

Rep: Reputation: 56
Vim & UTF-8


Please help

I'm working on a French website and having a horrible time getting Vim to edit the files without mangling the characters.

I can enter accented characters fine.. they appear properly in Vim, and when I save the file with fileencoding=utf-8 they show up in the browser properly as well.

The problem occurs when I have to edit a file with previously entered accented characters, they appear mangled. If I save a file with these mangled characters, they still appear properly in the browser.

However, when I enter new characters they appear properly in Vim, but NOT the browser. The old characters still appear properly. When I save the file with fileencoding=utf-8, then the new characters appear properly in the browser and the old characters are now broken.

It seems like I cannot enter new accented characters in a file without breaking the accented characters already present.

What am I doing wrong?
 
Old 08-26-2010, 03:42 PM   #2
Hidden Windshield
Member
 
Registered: Jul 2010
Distribution: Fedora
Posts: 68

Rep: Reputation: 27
Sounds to me like the files with previously entered accented characters aren't in UTF-8. So, when VIM tries to load them, they come through mangled.

What does the "file" command say when you run it on one of the files with previously entered accented characters? If it says anything other than "UTF-8 Unicode text", that's the problem. Use iconv to convert the files from whatever encoding they're in to UTF-8.
 
Old 08-27-2010, 09:23 AM   #3
mattca
Member
 
Registered: Jan 2009
Distribution: Slackware 14.1
Posts: 333

Original Poster
Rep: Reputation: 56
Code:
	[Fri Aug 27, 10:06:35] [~/mnt/m2w/dev.<snip>.com/system/application/controllers]
	[matt@turing] $ file -i awards.php
awards.php: text/x-php; charset=utf-8
I got it to work using this script, but I'm not sure what specifically made it work.

I also still cannot enter utf characters into the database, using the mysql command line or Vim's database plugin. I'm using rxvt-unicode and slackware 13.0 if it makes a difference.
 
Old 08-27-2010, 02:21 PM   #4
Hidden Windshield
Member
 
Registered: Jul 2010
Distribution: Fedora
Posts: 68

Rep: Reputation: 27
Hmm. I took a look at that script, and nothing jumped out at me except the terminal encoding. Maybe the terminal settings were wrong somehow? Anyway, glad you got it fixed.

As for MySQL, it uses Latin1 (ISO-8859-1) for most things, unless you specifically set it to something else. Running the command "SHOW VARIABLES LIKE 'character_set_client';" in the interactive client will show you what character set it's using to communicate with the client, for instance. You can find other such variables to check here. For individual tables, you have to use the "CHARACTER SET" attribute of char or varchar columns to get utf8, unless the table default is already utf8.

Hope this helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to input non-utf characters from utf-8 linux enviroment? jadas Linux - General 6 02-07-2009 03:20 PM
im getting UTF-8 to STRING: Could not open converter from 'UTF-8' to 'ISO-8859-1' jabka Linux - Newbie 2 11-24-2006 05:44 AM
How to edit UTF-8 file in VIM ? naihe2010 Programming 6 09-28-2006 01:36 AM
[Enter] in text documents diffrent on Windows and Linux? UTF-8/UTF-16 problem or? brynjarh Linux - General 1 11-24-2004 05:20 AM
PHP (substr) & UTF-8 liquid sky Programming 3 09-08-2004 12:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration