characters in python

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

    #1

    characters in python

    Can python handle this characters: ć,č,ž,đ,š?

    If can how"
  • Stens

    #2
    Re: characters in python

    Stens wrote:
    Can python handle this characters: ć,č,ž,đ,š?
    >
    If can how"
    Heh, It is from croatian language. So this characters are changed.

    Comment

    • Fredrik Lundh

      #3
      Re: characters in python

      Stens wrote:
      Can python handle this characters: ć,č,ž,đ,š?
      yes.
      If can how"
      depends on the use case: are you trying to put them in source code, in
      files, on the terminal, ... ?

      </F>

      Comment

      • Stens

        #4
        Re: characters in python

        Stens wrote:
        Can python handle this characters: ć,č,ž,đ,š?
        >
        If can how"
        I wanna to change some characters in text (in the file) to the
        characters at this address:


        Comment

        • Marc 'BlackJack' Rintsch

          #5
          Re: characters in python

          In <eh5t1s$bq2$3@s s408.t-com.hr>, Stens wrote:
          Stens wrote:
          >Can python handle this characters: ć,č,ž,đ,š?
          >>
          >If can how"
          I wanna to change some characters in text (in the file) to the
          characters at this address:
          >
          http://rapidshare.de/files/37244252/..._copy.png.html
          Do you want to change the characters in a picture!? Your question still
          is *very* vague. Please provide a more detailed description of the
          problem at hand.

          What do you have? A text file? In which encoding? And what do you want
          to achieve?

          Ciao,
          Marc 'BlackJack' Rintsch

          Comment

          • Leo Kislov

            #6
            Re: characters in python



            On Oct 18, 11:50 am, Stens <sgi...@email .t-com.hrwrote:
            Stens wrote:
            Can python handle this characters: c,c,ž,d,š?
            >
            If can how"I wanna to change some characters in text (in the file) to the
            characters at this address:
            >
            http://rapidshare.de/files/37244252/..._copy.png.html
            You need to use unicode, see any python unicode tutorial, for example
            this one http://www.amk.ca/python/howto/unicode or any other you can
            find with google.

            Your script can look like this:

            # -*- coding: PUT-HERE-ENCODING-OF-THIS-SCRIPT-FILE -*-
            import codecs
            outfile = codecs.open("yo ur output file", "w", "encoding of the output
            file"):
            for line in codecs.open("yo ur input file", "r", "encoding of the input
            file"):
            outfile.write(l ine.replace(u'd ',u'd'))

            Comment

            • Leo Kislov

              #7
              Re: characters in python


              Leo Kislov wrote using google groups beta:
              On Oct 18, 11:50 am, Stens <sgi...@email .t-com.hrwrote:
              Stens wrote:
              Can python handle this characters: c,c,ž,d,š?
              [snip]
              outfile.write(l ine.replace(u'd ',u'd'))
              I hope you'll do better than google engeers who mess up croatian
              characters in new google groups. Of course the last 'd' should be latin
              d with stroke. I really typed it but google swallowed the stroke.

              Comment

              • Gigs_

                #8
                Re: characters in python

                I solve it. Just have to do another encoding:
                This PEP proposes to introduce a syntax to declare the encoding of a Python source file. The encoding information is then used by the Python parser to interpret the file using the given encoding. Most notably this enhances the interpretation of Unicode ...

                Comment

                • Gigs_

                  #9
                  Re: characters in python

                  Leo Kislov wrote:
                  >
                  On Oct 18, 11:50 am, Stens <sgi...@email .t-com.hrwrote:
                  >Stens wrote:
                  >>Can python handle this characters: c,c,ž,d,š?
                  >>If can how"I wanna to change some characters in text (in the file) to the
                  >characters at this address:
                  >>
                  >http://rapidshare.de/files/37244252/..._copy.png.html
                  >
                  You need to use unicode, see any python unicode tutorial, for example
                  this one http://www.amk.ca/python/howto/unicode or any other you can
                  find with google.
                  >
                  Your script can look like this:
                  >
                  # -*- coding: PUT-HERE-ENCODING-OF-THIS-SCRIPT-FILE -*-
                  import codecs
                  outfile = codecs.open("yo ur output file", "w", "encoding of the output
                  file"):
                  for line in codecs.open("yo ur input file", "r", "encoding of the input
                  file"):
                  outfile.write(l ine.replace(u'd ',u'd'))
                  >
                  thx Leo

                  Comment

                  Working...