Results 1 to 7 of 7

Thread: UTF-8 characters on vi

  1. #1
    Join Date
    Sep 2009
    Location
    Alverca do Ribatejo, Portugal
    Posts
    53

    Question UTF-8 characters on vi

    Hi all!

    I have my OpenSuse 11.1 box set up with utf-8, however, every time I try to open a file with utf-8 characters with vi it can't handle those characters properly.

    What's might be the problem?

    Thanks.

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: UTF-8 characters on vi

    How do you know that the characters in the file are encoded in UTF-8? Have you tried doing an octal or hex dump of the file to check if perhaps the encoding is actually Latin-1?

    For example, I have a file with just the character and newline. Here's what it contains:

    Code:
    $ hexdump -C euro
    00000000  e2 82 ac 0a                                       |....|
    00000004

  3. #3
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,142

    Default Re: UTF-8 characters on vi

    Quote Originally Posted by jorgeraimundo View Post
    Hi all!

    I have my OpenSuse 11.1 box set up with utf-8, however, every time I try to open a file with utf-8 characters with vi it can't handle those characters properly.

    What's might be the problem?

    Thanks.
    When we start from the point that the system can not "know" if the file is UTF-8 from the outside. My experience is that vi does a very good guess normaly. That means when it finds out that a file contains bytes that cn not exist in UTF-8 encoded text it reverts to e.g. latin1. But when it is UTF-8 ots normaly treats it as that.

    Are you sure your file is UTF-8 encoded Unicode? How did you prove that to yourself?
    Henk van Velden

  4. #4
    Join Date
    Sep 2009
    Location
    Alverca do Ribatejo, Portugal
    Posts
    53

    Default Re: UTF-8 characters on vi

    Hi hen_yap!

    Thanks for your reply.

    In fact I don't even need to open a document. If I start a new file on vi, I'm unable to type properly the accentuated characters.

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,142

    Default Re: UTF-8 characters on vi

    Quote Originally Posted by jorgeraimundo View Post
    Hi hen_yap!

    Thanks for your reply.

    In fact I don't even need to open a document. If I start a new file on vi, I'm unable to type properly the accentuated characters.
    When you can not type accentuated characters, that has nothing to do with vi, but with your keyboard. How do you try to generate things like , etc?

    And to see what the vi thinks about the encoding of the current document, use the command
    Code:
    :set
    Henk van Velden

  6. #6
    Join Date
    Sep 2009
    Location
    Alverca do Ribatejo, Portugal
    Posts
    53

    Default Re: UTF-8 characters on vi

    Quote Originally Posted by hcvv View Post
    When you can not type accentuated characters, that has nothing to do with vi, but with your keyboard. How do you try to generate things like , etc?
    Hi hcvv!

    Thanks for your reply.

    My leyboards are fine, they work properly, but your remark made me discover the source of the problem .

    I'm using vi connected to the box via putty (therefore I'm using windows, and here I can type things like , so keyb is fine).

    Then I decided to try the server's keyboard to see if it works properly and I found out that, after all, everything works fine there. I can create, view and edit files on vi with accentuated characters.

    So my problem must be on some putty config that changes thins between my laptop and the server.

    Anyone had to deal with this before?

    Thanks.

  7. #7
    Join Date
    Sep 2009
    Location
    Alverca do Ribatejo, Portugal
    Posts
    53

    Default Re: UTF-8 characters on vi

    SOLVED!!!

    I found where to solve this.

    In putty configurations I went to "Window -> Translation" and changed the "Received data assumed to be in which character set:" parameter.

    Thanks for your time

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •