opening utf-16 fileencoded ucs-2 Little Endian

28 views
Skip to first unread message

Ni Va

unread,
Oct 1, 2021, 11:38:47 AM10/1/21
to vim_use
Hi All,


Got NLOG facility which encode in unicode a logfile that i am unable to open in vim whereas configuration I made.

This screenshot show the properly encoding format sawn by notepad++ (first taskbar with ucs) and the result in Vim with preconfiguration in vimrc

Capture.PNG

Christian Brabandt

unread,
Oct 1, 2021, 2:18:23 PM10/1/21
to vim...@googlegroups.com
Sorry only on a phone, but you can use :e ++enc=utf16le filename or similar 

Am 01.10.2021 um 17:38 schrieb Ni Va <niva...@gmail.com>:

Hi All,


Got NLOG facility which encode in unicode a logfile that i am unable to open in vim whereas configuration I made.

This screenshot show the properly encoding format sawn by notepad++ (first taskbar with ucs) and the result in Vim with preconfiguration in vimrc

<Capture.PNG>


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ca62bdf8-28df-4489-93ad-38e59e030ad4n%40googlegroups.com.
<Capture.PNG>

Ni Va

unread,
Oct 1, 2021, 3:26:31 PM10/1/21
to vim...@googlegroups.com
Already tested, no more result.

You received this message because you are subscribed to a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/92aX9rHFCeE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/528F969C-E7BF-4CE0-8069-512B2B5A37B8%40256bit.org.

Christian Brabandt

unread,
Oct 4, 2021, 5:25:27 AM10/4/21
to vim...@googlegroups.com

On Fr, 01 Okt 2021, Ni Va wrote:

> Already tested, no more result.

I am not sure what you are trying to say. FWIW: a regular UTF16 file
usually comes with a BOM, which allows Vim to detect the encoding
properly. If I use a testfile without a BOM I still can successfully
load it using `:e! ++enc=utf16le`

If this does not work for you can you please show an example file? Or do
you see any error message?

Best,
Christian
--
Besser heimlich schlau als unheimlich blöd.

Ni Va

unread,
Oct 4, 2021, 6:12:57 AM10/4/21
to vim...@googlegroups.com
Hi Christian,

No error message but I don't happen to read the file.


Capture.PNG


Here is an example file joined.

Thank you.
Nicolas

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/92aX9rHFCeE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_use+u...@googlegroups.com.
2021-10-01_NLOG.txt

Christian Brabandt

unread,
Oct 4, 2021, 6:44:19 AM10/4/21
to vim...@googlegroups.com

On Mo, 04 Okt 2021, Ni Va wrote:

> No error message but I don't happen to read the file.

And you did use ':e! ++enc=utf16le' for the already loaded file? Because
with this exact same command, I can reload the loaded file perfectly.

Alternatively, try to add utf16le to the (global) fileencodings
settings. But you need to add it before utf-8 I believe. So this should
also work:

':set fencs=ucs-bom,utf16le,utf-8,latin9'

But I am not sure, if this will not break for utf-8 files, so I tend to
only explicitly re-load files using the `:e ++enc ` command

BTW: please do not send screenshot files. I am using a text based mail
client, which makes it unnecessary hard to get the information.

Best,
Christian
--
Kalkulierter Gedächtnisverlust ist in der Politik ein
Überlebensmittel.
-- Hans Maier

Ni Va

unread,
Oct 4, 2021, 7:07:18 AM10/4/21
to vim...@googlegroups.com
Ok it works perfectly.

Thank you Christian.
Nicolas

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/92aX9rHFCeE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_use+u...@googlegroups.com.

Jürgen Krämer

unread,
Oct 4, 2021, 7:24:15 AM10/4/21
to vim...@googlegroups.com
Hi,

Christian Brabandt schrieb am 04.10.2021 um 12:44:
>
> On Mo, 04 Okt 2021, Ni Va wrote:
>
>> No error message but I don't happen to read the file.
>
> And you did use ':e! ++enc=utf16le' for the already loaded file? Because
> with this exact same command, I can reload the loaded file perfectly.
>
> Alternatively, try to add utf16le to the (global) fileencodings
> settings. But you need to add it before utf-8 I believe. So this should
> also work:
>
> ':set fencs=ucs-bom,utf16le,utf-8,latin9'
>
> But I am not sure, if this will not break for utf-8 files, so I tend to
> only explicitly re-load files using the `:e ++enc ` command

this will probably break utf-8 files without BOM. With BOM they would be
correctly detected by ucs-bom. Without a BOM all or almost all utf-8 files
can be interpreted as utf-16 -- even those with an odd number of bytes; in
this case Vim puts out a conversion error, but loads the file anyway. Even
incomplete surrogate pairs don't seem to prevent Vim from loading the file
as utf-16.

Better put utf16le after utf-8, because a misinterpretation of utf16 (both
little endian and big endian) can be detected by Vim.

But then you will probably run into the same dilemma with utf-16 and
latin9 ... :-(

Regards,
Jürgen

--
~
~
~
:wq

Ni Va

unread,
Oct 4, 2021, 7:38:28 AM10/4/21
to vim...@googlegroups.com
Hum I see Jürgen. Thank you.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/92aX9rHFCeE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_use+u...@googlegroups.com.

Ni Va

unread,
Oct 4, 2021, 12:02:22 PM10/4/21
to vim...@googlegroups.com
it's now my vimrc bad displayed with this fencs : set fencs=ucs-bom,utf16le,utf-8,latin9

Ni Va

unread,
Oct 4, 2021, 12:03:02 PM10/4/21
to vim...@googlegroups.com
this is better :   set fencs=ucs-bom,utf-8,utf16le,latin9

Ni Va

unread,
Oct 4, 2021, 12:03:39 PM10/4/21
to vim...@googlegroups.com
hum, now it's log UCS16 that is bad displayed.
Reply all
Reply to author
Forward
0 new messages