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

[Cheetahtemplate-discuss] cheetah not unicode compliant?!

Expand Messages
  • Miha Vrhovnik
    Hi! I m using Cheetah template 2.0 rc6 in embedded python 2.4 and in attached template i get: UnicodeDecodeError: ascii codec can t decode byte 0xc5 in
    Message 1 of 6 , Apr 3, 2006
      Hi!

      I'm using Cheetah template 2.0 rc6 in embedded python 2.4 and in
      attached template i get:

      UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position
      840: ordinal not in range(128).

      Cheetah template is called using following code:
      ---------------
      # -*- coding: UTF-8 -*-
      import overdue
      from Cheetah.Template import Template, Filters


      t = Template(file=overdue.tplFileName.Value, searchList=[{'overdue':
      overdue, 'languageCode' : 'sl'}])

      #get html from template
      overdue.templateResult.Value = t.__str__();
      ---------------

      Regards,
      Miha
    • Stephane Bortzmeyer
      On Mon, Apr 03, 2006 at 12:10:27PM +0100, Miha Vrhovnik wrote ... I use Cheetah with Unicode files: your subject is highly
      Message 2 of 6 , Apr 3, 2006
        On Mon, Apr 03, 2006 at 12:10:27PM +0100,
        Miha Vrhovnik <mvrhov@...> wrote
        a message of 138 lines which said:

        > I'm using Cheetah template 2.0 rc6 in embedded python 2.4 and in
        > attached template i get:

        I use Cheetah with Unicode files: your subject is highly misleading.

        > ##filter WebSafe #encoding UTF-8
        ^^^^^^^^^^^^^^^
        Should be on its own line.



        -------------------------------------------------------
        This SF.Net email is sponsored by xPML, a groundbreaking scripting language
        that extends applications into web and mobile media. Attend the live webcast
        and join the prime developer group breaking into this new coding territory!
        http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      • Mike Orr
        ... .__str__() doesn t work if the unicode contains non-ASCII characters. That s not a Cheetah problem, it s Python-wide. To get a unicode result: unicode(t)
        Message 3 of 6 , Apr 3, 2006
          On 4/3/06, Miha Vrhovnik <mvrhov@...> wrote:
          > Hi!
          >
          > I'm using Cheetah template 2.0 rc6 in embedded python 2.4 and in
          > attached template i get:
          >
          > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position
          > 840: ordinal not in range(128).
          >
          > Cheetah template is called using following code:
          > ---------------
          > # -*- coding: UTF-8 -*-
          > import overdue
          > from Cheetah.Template import Template, Filters
          >
          >
          > t = Template(file=overdue.tplFileName.Value, searchList=[{'overdue':
          > overdue, 'languageCode' : 'sl'}])
          >
          > #get html from template
          > overdue.templateResult.Value = t.__str__();

          .__str__() doesn't work if the unicode contains non-ASCII characters.
          That's not a Cheetah problem, it's Python-wide. To get a unicode
          result:

          unicode(t)
          t.respond() # Will be unicode if any part of the output is unicode.

          To get a string result:

          unicode(t).encode('utf-8')
          unicode(t).encode('latin-1')
          t.respond().encode('utf-8')

          This is in version 2 of the Users Guide (unreleased).

          --
          Mike Orr <sluggoster@...>
          (mso@... address is semi-reliable)


          -------------------------------------------------------
          This SF.Net email is sponsored by xPML, a groundbreaking scripting language
          that extends applications into web and mobile media. Attend the live webcast
          and join the prime developer group breaking into this new coding territory!
          http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        • Miha Vrhovnik
          ... #encoding UFT-8 is in new line. File uses windows line ending. Regards, Miha ... This SF.Net email is sponsored by xPML, a groundbreaking scripting
          Message 4 of 6 , Apr 5, 2006
            >I use Cheetah with Unicode files: your subject is highly misleading.
            >
            >> ##filter WebSafe #encoding UTF-8
            > ^^^^^^^^^^^^^^^
            > Should be on its own line.

            #encoding UFT-8 is in new line. File uses windows line ending.

            Regards,
            Miha


            -------------------------------------------------------
            This SF.Net email is sponsored by xPML, a groundbreaking scripting language
            that extends applications into web and mobile media. Attend the live webcast
            and join the prime developer group breaking into this new coding territory!
            http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
            _______________________________________________
            Cheetahtemplate-discuss mailing list
            Cheetahtemplate-discuss@...
            https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
          • Miha Vrhovnik
            ... I think that you are not right. At least I get properly encoded unicode from that in other cases. I pass every string variable as unicode, but other html
            Message 5 of 6 , Apr 5, 2006
              >.__str__() doesn't work if the unicode contains non-ASCII characters.
              >That's not a Cheetah problem, it's Python-wide. To get a unicode
              >result:
              I think that you are not right.
              At least I get properly encoded unicode from that in other cases.
              I pass every string variable as unicode, but other html files are plain ascii and things get translated via function calls. The one attached in 1st message is utf-8 encoded and it doesn't work.

              >unicode(t)
              >t.respond() # Will be unicode if any part of the output is unicode.
              I still get the same error.

              Regards,
              Miha


              -------------------------------------------------------
              This SF.Net email is sponsored by xPML, a groundbreaking scripting language
              that extends applications into web and mobile media. Attend the live webcast
              and join the prime developer group breaking into this new coding territory!
              http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
              _______________________________________________
              Cheetahtemplate-discuss mailing list
              Cheetahtemplate-discuss@...
              https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
            • Shannon -jj Behrens
              ... Make sure you guys are talking about the same version. -jj ... This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends
              Message 6 of 6 , Apr 5, 2006
                On 4/5/06, Miha Vrhovnik <mvrhov@...> wrote:
                > >.__str__() doesn't work if the unicode contains non-ASCII characters.
                > >That's not a Cheetah problem, it's Python-wide. To get a unicode
                > >result:
                > I think that you are not right.
                > At least I get properly encoded unicode from that in other cases.
                > I pass every string variable as unicode, but other html files are plain ascii and things get translated via function calls. The one attached in 1st message is utf-8 encoded and it doesn't work.
                >
                > >unicode(t)
                > >t.respond() # Will be unicode if any part of the output is unicode.
                > I still get the same error.

                Make sure you guys are talking about the same version.

                -jj


                -------------------------------------------------------
                This SF.Net email is sponsored by xPML, a groundbreaking scripting language
                that extends applications into web and mobile media. Attend the live webcast
                and join the prime developer group breaking into this new coding territory!
                http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
                _______________________________________________
                Cheetahtemplate-discuss mailing list
                Cheetahtemplate-discuss@...
                https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
              Your message has been successfully submitted and would be delivered to recipients shortly.