3

I have a file which shows different things in Notepad and Vim.

The file displays normally under Windows Notepad:

picture of file in Windows Notepad

Strange character are added to each character when using Vim.

picture of file in Vim

Anyone know how to dismiss those strange character in Vim under Windows environment?

Keith Pinson
  • 7,835
  • 7
  • 61
  • 104
TheOneTeam
  • 25,806
  • 45
  • 116
  • 158

3 Answers3

6

As you can see: TSS is displayed as T^@S^@S^@(binary: 54 00 53 00 53 00).
Because vim shows \0x00 as ^@. It sounds like UTF16LE.


You can convert UTF16LE to UTF8:

:e ++enc=UTF16LE
:set fenc=UTF8
:w
kev
  • 155,172
  • 47
  • 273
  • 272
1

That looks like unicode. You can open the file in notepad and save it as ascii.

Alternatively, if you don't want to create a new file, you can change your vimrc settings to enable multi-byte character encoding.

Here's more information from the vim wiki:
http://vim.wikia.com/wiki/Working_with_Unicode

hopia
  • 4,880
  • 7
  • 32
  • 54
1

The file is stored as UTF-16, where each character is represented by two bytes. VIM opens it as if it was an ASCII or UTF-8 file, so each pair of bytes is turned into two characters.

Notepad recognises the encoding, but apparently VIM doesn't. Specify the encoding when you open the file.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
  • Guffa: How can i do that in VIM? any ref link? hopia's solution not work :( – TheOneTeam Feb 06 '12 at 03:06
  • Have you read the info on the page he is linking to? What did you try? – johnny Feb 06 '12 at 04:36
  • @KitHo: That solution doesn't work because it uses UTF-8, not UTF-16. You could try the same with UTF-16le or UTF-16be. You can find some other possible solutions by searching http://www.google.se/search?q=vim+utf-16 – Guffa Feb 06 '12 at 07:14