By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,198 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

characters in python

P: n/a
Can python handle this characters: ć,č,ž,đ,š?

If can how"
Oct 18 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Stens wrote:
Can python handle this characters: ć,č,ž,đ,š?

If can how"
Heh, It is from croatian language. So this characters are changed.
Oct 18 '06 #2

P: n/a
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>

Oct 18 '06 #3

P: n/a
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
Oct 18 '06 #4

P: n/a
In <eh**********@ss408.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
Oct 18 '06 #5

P: n/a


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("your output file", "w", "encoding of the output
file"):
for line in codecs.open("your input file", "r", "encoding of the input
file"):
outfile.write(line.replace(u'd',u'd'))

Oct 18 '06 #6

P: n/a

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(line.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.

Oct 18 '06 #7

P: n/a
I solve it. Just have to do another encoding:
http://www.python.org/dev/peps/pep-0263/
Oct 19 '06 #8

P: n/a
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("your output file", "w", "encoding of the output
file"):
for line in codecs.open("your input file", "r", "encoding of the input
file"):
outfile.write(line.replace(u'd',u'd'))
thx Leo
Oct 19 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.