Loading ...
Sorry, an error occurred while loading the content.

what locale?

Expand Messages
  • Valery Kondakoff
    Hello, Jason! ... MJ perhaps you should run vim under a utf-8 locale, then try MJ strftime with set encoding=utf8 MJ my advice is use utf-8 for
    Message 1 of 8 , Mar 20, 2003
    • 0 Attachment
      Hello, Jason!

      Thursday, March 20, 2003, you wrote to me:

      >>As far as I understand the only way to stop strftime() to produce
      >>garbage whith local verbose month name is _not_ to use 'set
      >>encoding=utf-8'.

      MJ> perhaps you should run vim under a utf-8 locale, then try
      MJ> strftime with "set encoding=utf8"
      MJ> my advice is use utf-8 for everything, and just forget cp-whatever
      MJ> ever existed :)

      Sounds promising! :)

      Do you have an idea how to run Vim under utf-8 locale in WinXP? (I
      mentioned in "initial" message, that I'm working under WinXP).

      Thank you.

      --
      Best regards,
      Valery Kondakoff
      http://www.nbk.orc.ru (Ne Bey Kopytom)
      http://www.nbk.orc.ru/mtb (MTB riding in Moscow)

      PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...

      np: The Third Eye Foundation - A Galaxy Of Scars (You Guys Kill Me)
    • Bram Moolenaar
      ... Why convert from encoding to the locale first? I would think this is ASCII thus doesn t need to be converted. If we do this, do we have to do the
      Message 2 of 8 , Mar 20, 2003
      • 0 Attachment
        Daniel Elstner wrote:

        > Yes, that would work. What f_strftime() should do is converting from
        > 'encoding' to the current locale before calling the system's strftime(),
        > and vice versa afterwards. I'd come up with a patch but unfortunately
        > Vim internally doesn't have a stardard mechanism to convert from/to the
        > current locale (as it does have for 'termencoding').

        Why convert from 'encoding' to the locale first? I would think this is
        ASCII thus doesn't need to be converted. If we do this, do we have
        to do the conversion before calling any library function? And before
        passing a command to a shell? Don't think so.

        > Bram: I think enc_default() should remember the locale encoding for
        > later use, as needed for strftime() and other locale-dependent system
        > functions. What do you think?

        calling enc_default() once won't catch all situations. You can do:

        :let $LANG=de

        Thus the encoding needs to be obtained the moment strftime() is invoked.
        Rewriting enc_default() to something more generic would be required.

        --
        hundred-and-one symptoms of being an internet addict:
        158. You get a tuner card so you can watch TV while surfing.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
      • Daniel Elstner
        ... Apart from % escapes, the string passed to strftime() may contain anything, just like the format string for printf(). Non-ASCII characters will be
        Message 3 of 8 , Mar 20, 2003
        • 0 Attachment
          On Don, 2003-03-20 at 23:11, Bram Moolenaar wrote:
          > Daniel Elstner wrote:
          >
          > > Yes, that would work. What f_strftime() should do is converting from
          > > 'encoding' to the current locale before calling the system's strftime(),
          > > and vice versa afterwards. I'd come up with a patch but unfortunately
          > > Vim internally doesn't have a stardard mechanism to convert from/to the
          > > current locale (as it does have for 'termencoding').
          >
          > Why convert from 'encoding' to the locale first? I would think this is
          > ASCII thus doesn't need to be converted.

          Apart from '%' escapes, the string passed to strftime() may contain
          anything, just like the format string for printf(). Non-ASCII
          characters will be mangled if the conversion is only done afterwards.

          > If we do this, do we have
          > to do the conversion before calling any library function? And before
          > passing a command to a shell? Don't think so.

          Not any function, but for strftime() it _is_ necessary. BTW GLib2 also
          does the conversion in g_date_strftime().

          > > Bram: I think enc_default() should remember the locale encoding for
          > > later use, as needed for strftime() and other locale-dependent system
          > > functions. What do you think?
          >
          > calling enc_default() once won't catch all situations. You can do:
          >
          > :let $LANG=de
          >
          > Thus the encoding needs to be obtained the moment strftime() is invoked.
          > Rewriting enc_default() to something more generic would be required.

          Ahh OK. I didn't know Vim might change the locale at runtime.

          --Daniel
        • Daniel Elstner
          ... Patch attached. I renamed enc_default() to enc_locale(), made it return an allocated string, and moved the code to set p_enc into src/option.c. Also I
          Message 4 of 8 , Mar 21, 2003
          • 0 Attachment
            On Don, 2003-03-20 at 23:11, Bram Moolenaar wrote:
            > Daniel Elstner wrote:
            > > Bram: I think enc_default() should remember the locale encoding for
            > > later use, as needed for strftime() and other locale-dependent system
            > > functions. What do you think?
            >
            > calling enc_default() once won't catch all situations. You can do:
            >
            > :let $LANG=de
            >
            > Thus the encoding needs to be obtained the moment strftime() is invoked.
            > Rewriting enc_default() to something more generic would be required.

            Patch attached. I renamed enc_default() to enc_locale(), made it return
            an allocated string, and moved the code to set p_enc into src/option.c.
            Also I generalized convert_setup() a bit so that the caller is no longer
            required to explicitely initialize the iconv-specific struct members.

            There's one problem with this patch though, according to this comment
            regarding convert_setup():

            /*
            * Setup "vcp" for conversion from "from" to "to".
            * The names must have been made canonical with enc_canonize().
            * Note: cannot be used for conversion from/to ucs-2 and ucs-4 (will use utf-8
            * instead).
            */

            I reckon that might cause problems at least on Win32. I don't though
            know if strftime() on Windows will ever use UCS-2, UTF-16 or UCS-4.

            --Daniel
          • Bram Moolenaar
            ... That looks good. ... That doesn t appear to work properly, because vcp- vc_type is not always initialized. That can be fixed and then setting vcp- vc_fd
            Message 5 of 8 , Mar 21, 2003
            • 0 Attachment
              Daniel Elstner wrote:

              > > Daniel Elstner wrote:
              > > > Bram: I think enc_default() should remember the locale encoding for
              > > > later use, as needed for strftime() and other locale-dependent system
              > > > functions. What do you think?
              > >
              > > calling enc_default() once won't catch all situations. You can do:
              > >
              > > :let $LANG=de
              > >
              > > Thus the encoding needs to be obtained the moment strftime() is invoked.
              > > Rewriting enc_default() to something more generic would be required.
              >
              > Patch attached. I renamed enc_default() to enc_locale(), made it return
              > an allocated string, and moved the code to set p_enc into src/option.c.

              That looks good.

              > Also I generalized convert_setup() a bit so that the caller is no longer
              > required to explicitely initialize the iconv-specific struct members.

              That doesn't appear to work properly, because vcp->vc_type is not always
              initialized. That can be fixed and then setting vcp->vc_fd doesn't
              need to be set before calling convert_setup().

              You forgot to free the result of convert_setup().

              I have fixed these issues and I'll send out a patch after a few tests.

              > There's one problem with this patch though, according to this comment
              > regarding convert_setup():
              >
              > /*
              > * Setup "vcp" for conversion from "from" to "to".
              > * The names must have been made canonical with enc_canonize().
              > * Note: cannot be used for conversion from/to ucs-2 and ucs-4 (will use utf-8
              > * instead).
              > */
              >
              > I reckon that might cause problems at least on Win32. I don't though
              > know if strftime() on Windows will ever use UCS-2, UTF-16 or UCS-4.

              I don't think that strftime() would work with UCS-2, since a string
              may contain NUL bytes.

              --
              "Hit any key to continue" does _not_ mean you can hit the on/off button!

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
              \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
              \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
            • Daniel Elstner
              ... Yes -- I said iconv-specific struct members. ... That s what I did in f_strftime(). ... Actually I didn t... but I did indeed forget to vim_free(enc) :-)
              Message 6 of 8 , Mar 21, 2003
              • 0 Attachment
                On Fre, 2003-03-21 at 21:09, Bram Moolenaar wrote:
                > >
                > > Patch attached. I renamed enc_default() to enc_locale(), made it return
                > > an allocated string, and moved the code to set p_enc into src/option.c.
                >
                > That looks good.
                >
                > > Also I generalized convert_setup() a bit so that the caller is no longer
                > > required to explicitely initialize the iconv-specific struct members.
                >
                > That doesn't appear to work properly, because vcp->vc_type is not always
                > initialized.

                Yes -- I said "iconv-specific" struct members.

                > That can be fixed and then setting vcp->vc_fd doesn't
                > need to be set before calling convert_setup().

                That's what I did in f_strftime().

                > You forgot to free the result of convert_setup().

                Actually I didn't... but I did indeed forget to vim_free(enc) :-)

                > I have fixed these issues and I'll send out a patch after a few tests.

                Cool.

                > > I reckon that might cause problems at least on Win32. I don't though
                > > know if strftime() on Windows will ever use UCS-2, UTF-16 or UCS-4.
                >
                > I don't think that strftime() would work with UCS-2, since a string
                > may contain NUL bytes.

                Sure, though actually strftime() returns the length. But I also think
                it's unlikely that strftime() was ever meant to work with UCS-2 or
                UCS-4.

                --Daniel
              Your message has been successfully submitted and would be delivered to recipients shortly.