R
rusi
You should *read* and *understand* the error message!
When you *shout* at the deaf, the non-deaf get deaf <wink>.
You should *read* and *understand* the error message!
MRAB tells you to work with the bytes, because the filenames' bytes are
invalid decoded as UTF-8. If you fix the file names by renaming using a
terminal set to UTF-8, then they will be valid and you can forget about
working with bytes.
Working with bytes is only for when the file names are turned to garbage.
Your file names (some of them) are turned to garbage. Fix them, and then
use file names as strings.
Yes, but but 'putty' seems to always forget when i tell it to use utf8 for displaying and always picks up the Win8's default charset and it doesnt have a save options dialog. I cant always remember to switch to utf8 charsetor renaming all the time from termnal so many greek filenames.
How can it be correct? We have encoded out string in utf-8 and then we| Τη Î Îμπτη, 6 Ιουνίου 2013 3:44:52 μ.μ. UTC+3, ο χÏήστης Steven D'Aprano ÎγÏαψε:
| > py> s = '999-Eυχή-του-ΙησοÏ'
| > py> bytes_as_utf8 = s.encode('utf-8')
| > py> t = bytes_as_utf8.decode('iso-8859-7', errors='replace')
| > py> print(t)
| > 999-EΟΟΞ�-ΟΞÎΟ-ΞΞ·ΟΞÎΟ
|
| errors='replace' mean dont break in case or error?
Yes. The result will be correct for correct iso-8859-7 and slightly mangled
for something that would not decode smoothly.
Same as above, i don't understand it at all, since different| You took the unicode 's' string you utf-8 bytestringed it.
| Then how its possible to ask for the utf8-bytestring to decode
| back to unicode string with the use of a different charset that the
| one used for encoding and thsi actually printed the filename in
| greek-iso?
It is easily possible, as shown above. Does it make sense? Normally
not, but Steven is demonstrating how your "mv" exercises have
behaved: a rename using utf-8, then a _display_ using iso-8859-7.
That means that, when a linux application needs to saved a filename to|
| a) WHAT does it mean when a linux system is set to use utf-8?
It means the locale settings _for the current process_ are set for
UTF-8. The "locale" command will show you the current state.
| c) WHAT happens when the two of them try to work together?
If everything matches, it is all good. If the locales do not match,
the mismatch will result in an undesired bytes<->characters
encode/decode step somewhere, and something will display incorrectly
or be entered as input incorrectly.
I use PuTTY too (though that'll change when I next upgrade Traal, as
I'll no longer have any Windows clients), and it's set to UTF-8 in the
Winoow|Translation page. Far as I know, those settings are all saved
into the Saved Sessions settings, back on the Session page.
ChrisA
File "files.py", line 75
os.rename( filepath_bytes filepath.encode('utf-8') )
^
SyntaxError: invalid syntax
I am seeign the caret pointing at filepath but i cant follow what it
tries to tell me.
This rename statement tries to convert the greek byted filepath to
utf-8 byted filepath.
I can't see whay this is wrong though.
I'll google Traal right now.
As already explained, often a SyntaxError is introduced by *preceeding*
"text", so you must look at your code with a "wider eye".
Yes: and that usually imply that the *function* accepts (at least) *two*
arguments, specifically the source and the target names, right? How many
arguments are you actually giving to the os.rename() function above?
Τη ΠαÏασκευή, 7 Ιουνίου 2013 10:09:29 Ï€.μ. UTC+3, ο χÏήστης Lele Gaifax ÎγÏαψε:
That what i ahte aabout error reporting. You have some syntax error someplace and error reports you another line, so you have to check the whole code again.
Well i just did, i see no syntactical errors.
i'm giving it two.
os.rename( filepath_bytes filepath.encode('utf-8')
I doubted that os.rename arguments must be comma seperated.os.rename( filepath_bytes filepath.encode('utf-8')
Missing comma, which is, after all, just a matter of syntax so it can't matter, right?
Can't '~/data/apps/' is filled every day with more and more files which
are uploaded via FileZilla client, which i think it behaves pretty much
like putty, uploading filenames as greek-iso bytes.
Session settings afaik is for putty to remember hosts to connect to,
not terminal options. I might be worng though. No matter how many times
i change its options next time i run it always defaults back.
My web page: <http://coyoteden.dyndns-free.com:85/gene> is up!
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.