summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <eevee.git@veekun.com>2013-08-21 15:33:21 -0700
committerEevee (Alex Munroe) <eevee.git@veekun.com>2013-08-21 15:33:21 -0700
commite40bbc1851d5c087f78a05cb0bf74f129d16c3a9 (patch)
tree81ba92ccfa7ad5517ac5fcf3a69395979933439a
parentd1de124c090662c515939cb8032651442aaf32af (diff)
downloadpyscss-e40bbc1851d5c087f78a05cb0bf74f129d16c3a9.tar.gz
Default String encoding to UTF-8. Sigh.
-rw-r--r--scss/types.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/scss/types.py b/scss/types.py
index 8ab300e..29b512d 100644
--- a/scss/types.py
+++ b/scss/types.py
@@ -818,6 +818,9 @@ class Color(Value):
return candidates[0]
+# TODO be unicode-clean and delete this nonsense
+DEFAULT_STRING_ENCODING = "utf8"
+
class String(Value):
"""Represents both CSS quoted string values and CSS identifiers (such as
`left`).
@@ -840,8 +843,7 @@ class String(Value):
value = str(value)
if isinstance(value, six.binary_type):
- # TODO this blows! need to be unicode-clean so this never happens.
- value = value.decode('ascii')
+ value = value.decode(DEFAULT_STRING_ENCODING)
if not isinstance(value, six.text_type):
raise TypeError("Expected string, got {0!r}".format(value))
@@ -852,8 +854,8 @@ class String(Value):
if six.PY3:
self.value = value
else:
- # TODO not unicode clean on 2 yet...
- self.value = value.encode('ascii')
+ # TODO well, at least 3 uses unicode everywhere
+ self.value = value.encode(DEFAULT_STRING_ENCODING)
self.quotes = quotes
@classmethod