Daniel Dadush wrote:
Hi, I'm trying to do some work in i18n and I've having trouble getting
vim to properly display text in different languages. I'm currently
working with the MoinMoin wiki, looking at it's translatable text
strings (which are in 18 different languages) and almost all of them
render with strange characters on the screen. I set both file-encoding
and encoding to utf-8 and still no luck. If I open this files in IDLE
(the python editor) all the text displays perfectly, so I'm pretty
sure I have all the right language packs installed (I think...). Does
anyone know what I'm doing wrong? Any suggestions would be highly
appreciated.

Vim Version: 7.0
OS: WinXP SP2



Oops.

To have Vim display file data properly, you need the following:

1) a version of gvim with +multi_byte compiled-in: ":echo has("multi_byte") should return 1 2) a font which contains the proper glyphs. This can be set by means of the 'guifont' option, whose acceptable values vary between versions of the GUI. Here's an example of how to set it "portably" in your vimrc:

  if has("gui_running")
    if has("gui_gtk2")
      set gfn=Adobe\ Courier\ 12
    elseif has("gui_kde")
      set gfn=Adobe\ Courier/12
    elseif has("x11") " also for GTK+1
      set gfn=*-courier-medium-r-normal-*-*-160-*-*-m-*-*
    else " Windows, non-X11 Mac, etc.
      set gfn=Courier_New:h12
    endif
  endif

3) gvim must know in which charset the file was written. Method 1: Automatic recognition. The following will recognise any Unicode file if it has a BOM, UTF-8 files even without a BOM, and default the rest to Latin1. It will, however, open 7-bit US-ASCII files as UTF-8 because 7-bit ASCII data is valid UTF-8:

        :set fileencodings=ucs-bom,utf-8,latin1

3bis) Method 2: Manual recognition. If you have a file in a strange charset, you can tell Vim which 'fileencoding' to use:

        :edit ++enc=ko18-r russkij_tekst.txt


Best regards,
Tony.

Reply via email to