sys.setdefaultencoding(name)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Askari

    sys.setdefaultencoding(name)

    Where is the method : "sys.setdefault encoding(name)" ?

    Problem :
    I want change the default encoding because I want put french letter :
    éÉàÀ...etc in widget with no problem! When I use the method ".get" from a
    widget (Text, Entry), the string returned is "fucked"...
    In the Entry widget, the text is (with .insert) "été"
    When I add a "é" at end (with my keyboard), th result is "étéé" OR a
    raised error!

    I find, on net, that I must use "sys.setdefault encoding(name)" .
    I find find this methode in the doc (official) but the
    "setdefaultenco ding" name method is not in the sys module!?! (when I print
    "dir(sys)"? ! :-(

    Askari
  • Harald Massa

    #2
    Re: sys.setdefaulte ncoding(name)

    Askari,
    [color=blue]
    > When I use the method ".get" from a widget (Text, Entry), the string
    > returned is "fucked"...[/color]

    That must be a virus or something. Encoding issues normally provide garbled
    strings, but not the word "fucked". Somebody is playing jokes with you.
    [color=blue]
    > I find, on net, that I must use "sys.setdefault encoding(name)" .[/color]

    setdefaultencod ing gets removed from sys after execution of site.py /
    sitecustomize.p y.

    My solution is to grab site.py, dig up "default encoding" and change from
    imperalistic ASCII to LATIN-1.

    Some told me that avangarde persons also take UTF8.

    Harald

    Comment

    • Reinhold Birkenfeld

      #3
      Re: sys.setdefaulte ncoding(name)

      Harald Massa wrote:[color=blue]
      > Askari,
      >[color=green]
      >> When I use the method ".get" from a widget (Text, Entry), the string
      >> returned is "fucked"...[/color]
      >
      > That must be a virus or something. Encoding issues normally provide garbled
      > strings, but not the word "fucked". Somebody is playing jokes with you.[/color]

      I doubt that the quotes in the OP indicate a literal string.

      Reinhold

      --
      [Windows ist wie] die Bahn: Man muss sich um nichts kuemmern, zahlt fuer
      jede Kleinigkeit einen Aufpreis, der Service ist mies, Fremde koennen
      jederzeit einsteigen, es ist unflexibel und zu allen anderen Verkehrs-
      mitteln inkompatibel. -- Florian Diesch in dcoulm

      Comment

      • Askari

        #4
        Re: sys.setdefaulte ncoding(name)

        Harald Massa <cpl.19.ghum@sp amgourmet.com> wrote in
        news:Xns9568A73 F4BFF9cpl19ghum spamgourmet@195 .20.224.116:
        [color=blue]
        > My solution is to grab site.py, dig up "default encoding" and change
        > from imperalistic ASCII to LATIN-1.[/color]

        euh... I try (the line #2 and #3 in my ".py"):
        """
        import site
        site.encoding = "latin_1"
        """

        but I have this error when I modify a widget (with keyboard) I have this
        error :
        """
        UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0xc9 in position 0:
        ordinal not in range(128)
        """

        Why?
        And, I do the good think? (site.encoding = "latin_1")


        Askari

        Comment

        • Harald Massa

          #5
          Re: sys.setdefaulte ncoding(name)

          Askari,
          [color=blue]
          > """
          > import site
          > site.encoding = "latin_1"
          > """
          >
          > Why?
          > And, I do the good think? (site.encoding = "latin_1")[/color]

          No, you do a the bad thing.

          You have to EDIT the site.py within python\lib\site .py

          open it within an editor, find "ASCII" and replace by latin1

          site.encodiging ="Latin_1" just adds an attribute NOBODY cares for to a
          module in memory.

          Harald

          Comment

          • Askari

            #6
            Re: sys.setdefaulte ncoding(name)

            Harald Massa <cpl.19.ghum@sp amgourmet.com> wrote in
            news:Xns9569F39 D2C884cpl19ghum spamgourmet@195 .20.224.116:
            [color=blue]
            > Askari,
            >[color=green]
            >> """
            >> import site
            >> site.encoding = "latin_1"
            >> """
            >>
            >> Why?
            >> And, I do the good think? (site.encoding = "latin_1")[/color]
            >
            > No, you do a the bad thing.
            >
            > You have to EDIT the site.py within python\lib\site .py
            >
            > open it within an editor, find "ASCII" and replace by latin1
            >
            > site.encodiging ="Latin_1" just adds an attribute NOBODY cares for to a
            > module in memory.
            >
            > Harald
            >[/color]

            It work! :-)

            Thanks!

            Comment

            Working...