On 02/12/09 12:18, Mojca Miklavec wrote:
> On Wed, Dec 2, 2009 at 10:19, Mojca Miklavec wrote:
>> Hello,
>>
>> I have submitted Slovenian Vim menu translation a while ago while I
>> was still using XP (and then didn't use Windows for ages; menu
>> translations don't work with Aqua Vim at all) and the encoding worked 
>> properly.
>>
>> Now I tried it on Windows 7 and discovered that the language is set to
>> Slovenian_Slovenia.1250. That might be a bit weird. The native
>> encoding used to be cp1250 indeed (at least in XP), but it could be
>> that Windows 7 now
>> tries to use utf-8 whenever possible ... but I don't really know.
>
> I'm sorry for overflooding the mailing list. I have now figured out
> that I should be able to change the language with
>      gvim --cmd "lang Slovenian_Slovenia.65001"
> where 65001 is the windows code for UTF-8. This still means that
> "system-wide encoding for applications that are not UTF-8 aware" is
> cp1250 though. Just gvim is taught to use 65001 encoding. I copied the
> file menu_sl_si.utf-8.vim to menu_slovenian_slovenia.65001.vim if I
> wanted to be able to set that encoding at all, but gvim nevertheless
> seem to send cp1250-encoded data to Windows while windows interprets
> that data as if it was proper UTF-8.
>
> This seems like a "buglet" burried deep down in the source code. I
> wonder that no Czeck/Slovak/Polish users have complained so far.
>
> Mojca
>
> PS: possibly related problem that I had in past (sorry, I don't know
> where the offcial archive is):
>      http://markmail.org/message/5onmtz33tfohtvfz
> Subject: vim + win + utf-8 =>  I'm lost
> Date: Aug 4, 2005 5:23:05 pm
>

Hello Mojca,

I'm sorry no one answered your posts in almost one month (or only by 
breaking the thread).

To see which locale the OS passes to Vim, load it as

        gvim -N -u NONE

and then type

        :language

This will show you all parts of the locale: LC_MESSAGES for menus & 
messages translations, LC_CTYPE for character encoding, LC_TIME for 
timestamp format, and a bunch of others which I don't think Vim uses. 
(These are Unix-like names but I remember from my years on XP that 
they're also used in Vim for Windows.)

Windows codepage 1250 is a "Central European" encoding which is OK for 
formerly Czechoslovak countries and for those formerly Yugoslav 
countries which use the Latin alphabet; but of course Vim and the OS 
must agree on which encoding is to be used to transmit keystrokes from 
the keyboard to Vim and, in console Vim, from Vim to the screen. (gvim 
displays its text on its own graphical screen without passing _text_ to 
the OS for displaying.)

Yes, if 65001 is the Windows name for UTF-8, then you could indeed copy 
the menu (and helpfiles) with names ending in .utf-8 or .utf-8.vim etc. 
to files of the same name with the .utf8 replaced by .65001 (Why can't 
Windows use sl_SI.UTF-8 like Unix does? I suppose Bill Gate$$$ wants to 
keep his users captive and prevent them for escaping to Unix/Linux. Oh 
well...)

Beware though that any file in the $VIMRUNTIME tree can be modified or 
erased without warning any time you upgrade Vim and/or its runtime 
files, so when release 7.3 (or, who knows?, 8.0) gets published, be sure 
to copy your files again. On Linux you could set up 
$VIM/vimfiles/menu_slovenian_slovenia.65001.vim as a soft link to 
../latest/menu_sl_si.utf-8.vim with $VIM/latest as a soft link to the 
current $VIMRUNTIME but of course AFAIK soft links are foreign to 
Windows so I suppose you'll have to resort to copying. Just be sure that 
upgrading Vim doesn't remove your copies.

Or else, you could set 'encoding' to UTF-8 if it isn't already, before 
loading or reloading the menus. Maybe the following (untested) could 
work, at the very top of your vimrc, and regardless of the OS locale:

set nocompatible
if has('multi_byte')            " no use to try if Vim can't do it
        if &enc !~? '^u'        " already Unicode?
                if &tenc == ''  " don't clobber keyboard encoding
                        let &tenc = &enc        " the «old» value
                endif
                set enc=utf-8
        endif
        set fencs=ucs-bom,utf-8,cp1250  " how to detect
                                        " existing files' encodings
        " or:
        " set fencs=ucs-bom,utf-8,default,iso-8859-2
        " etc. (see :help 'fileencodings')
        if has('multi_lang')
        " I think the following commented-out line is unnecessary
        "       runtime delmenu.vim
                if exists(':try') == 2
                        try
                                lang messages sl_si.utf-8
                        catch
                                silent! lang messages
                                \ Slovenian_Slovenia.65001
                        endtry
                else
                        silent! lang messages sl_si.utf-8
                        if v:lang != 'sl_si.utf-8'
                                silent! lang messages
                                \ Slovenian_Slovenia.65001
                        endif
                endif
        endif
endif
runtime vimrc_example.vim
" add additional customizations here

(the vimrc_example.vim does, among others, ":filetype plugin indent on" 
and ":syntax on", and the menus are sourced, in gvim, as a result of that.)


Best regards,
Tony.
-- 
Ambition is a poor excuse for not having sense enough to be lazy.
                -- Charlie McCarthy

-- 
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui