Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Support Unicode in file names on Windows NT #275

Merged
merged 1 commit into from

2 participants

@grawity

Windows NT has two versions of most APIs – ANSI and Unicode. When given an unicode() object as the file name, Python uses the Unicode APIs, removing the need for manual filename encoding. (In fact, the manual encoding breaks things in such cases as, for example, Japanese or Korean names on an English system.)

@phihag phihag merged commit 99d46e8 into rg3:master
@phihag
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 16, 2012
  1. @grawity
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +8 −1 youtube_dl/__init__.py
View
9 youtube_dl/__init__.py
@@ -305,7 +305,14 @@ def _encodeFilename(s):
"""
assert type(s) == type(u'')
- return s.encode(sys.getfilesystemencoding(), 'ignore')
+
+ if sys.platform == 'win32' and sys.getwindowsversion().major >= 5:
+ # Pass u'' directly to use Unicode APIs on Windows 2000 and up
+ # (Detecting Windows NT 4 is tricky because 'major >= 4' would
+ # match Windows 9x series as well. Besides, NT 4 is obsolete.)
+ return s
+ else:
+ return s.encode(sys.getfilesystemencoding(), 'ignore')
class DownloadError(Exception):
"""Download Error exception.
Something went wrong with that request. Please try again.