LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-27-2006, 04:31 AM   #1
naihe2010
Member
 
Registered: Oct 2005
Location: China
Distribution: ArchLinux
Posts: 103

Rep: Reputation: 15
How to edit UTF-8 file in VIM ?


When I use Windows & IE, I downloaded lots of html file, and them be encoded by UTF-8.

Now, I want to edit them in VIM.

But, all the Unicode characters are wrong.

I use "set encoding=utf-8", but it doesn't work well. That is, all the
wrong characters are changed, but they are wrong, too.

How to solve this problem?

addtion:
I use Slackware+rxvt+vim
 
Old 09-27-2006, 09:58 AM   #2
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
When I save a source file it saves as ANSI not UTF-8 unless your changeing the encoding or something ?
 
Old 09-27-2006, 10:39 AM   #3
silent_cutthroat
LQ Newbie
 
Registered: Nov 2005
Distribution: Arch
Posts: 27

Rep: Reputation: 15
:e ++enc=utf-8 <your-file-name>

I use utf-8 locale and don't have any problems with utf-8.
 
Old 09-27-2006, 12:18 PM   #4
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Slackware doesn't build UTF-8 support into vim. You can get a version with utf-8 support from the Japanese on Slack project, build it yourself, or perhaps convert it to EUC and back again.
 
Old 09-27-2006, 07:55 PM   #5
naihe2010
Member
 
Registered: Oct 2005
Location: China
Distribution: ArchLinux
Posts: 103

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by silent_cutthroat
:e ++enc=utf-8 <your-file-name>

I use utf-8 locale and don't have any problems with utf-8.
How to use utf-8 locale ?
 
Old 09-27-2006, 07:59 PM   #6
naihe2010
Member
 
Registered: Oct 2005
Location: China
Distribution: ArchLinux
Posts: 103

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by tuxdev
Slackware doesn't build UTF-8 support into vim. You can get a version with utf-8 support from the Japanese on Slack project, build it yourself, or perhaps convert it to EUC and back again.
I downloaded the vim7.0's source file, but I can't find the utf-8 support in the "./configure --help".

and this is my vim's version
Code:
VIM - Vi IMproved 6.3 (2004 June 7, compiled Sep 10 2005 15:25:19)
Included patches: 1-86
Compiled by root@midas
Big version with GTK2 GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent 
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
+cryptv +cscope +dialog_con_gui +diff +digraphs +dnd -ebcdic +emacs_tags +eval 
+ex_extra +extra_search +farsi +file_in_path +find_in_path +folding -footer 
+fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap
 +libcall +linebreak +lispindent +listcmds +localmap +menu +mksession 
+modify_fname +mouse +mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm 
+mouse_netterm +mouse_xterm +multi_byte +multi_lang +netbeans_intg -osfiletype 
+path_extra -perl +postscript +printer -python +quickfix +rightleft -ruby 
+scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax 
+tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse 
+textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual 
+visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup 
+X11 -xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save 
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/X11R6/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/freetype2/config -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include     -O2  -I/usr/X11R6/include      
Linking: gcc  -L/usr/X11R6/lib   -L/usr/local/lib -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -lXt -lncurses -lgpm
It has a "+multi_byte", and is it really not build utf-8 support?

Last edited by naihe2010; 09-27-2006 at 08:01 PM.
 
Old 09-28-2006, 01:36 AM   #7
silent_cutthroat
LQ Newbie
 
Registered: Nov 2005
Distribution: Arch
Posts: 27

Rep: Reputation: 15
The vim online docs - http://www.vim.org/htmldoc/mbyte.html

Quote:
Originally Posted by naihe2010
How to use utf-8 locale ?
You set the LANG environment variable to something like en_US.utf-8, to see the supported locales - 'locale -a'. LANG is set in some of the scripts run on startup, to change your locale for all the users you shoud set LANG from there, but I can't remeber exactly where. Look at /etc/profile.d/ and /etc/rc.d/.

Also see the locale man page.
 
  


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
UTF-8 text file infected? kpachopoulos Linux - General 1 01-12-2006 07:37 PM
How do I know how a file is encoded? UTF-8, UTF-16, etc.. ?? brynjarh Linux - General 1 12-03-2004 11:11 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
X11 / UTF-8 locale seems missing 'fr_FR.UTF-8' chrsitophermann Debian 11 07-17-2004 02:04 PM
UTF file in bash? robertmarkbram Linux - General 1 12-11-2003 09:05 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:44 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