On 19/01/2015 at 17:00, xxxxxxxx wrote:
Hi conner,
I had to edit the message because I got some advice to give an answer that covers all of C4D / Python's UTF-8 character set.
This exact problem is why I don't spell my last name with the "é" inside most software ("Gaspé"), as the computer world is several years away from fully supporting Unicode, let alone IBM PC extended ASCII, and some try but get it all mixed up across the different encodings. It's one of those 'weakest link' issues.
I managed to reproduce the problem and found what should be the solution in this case. C4D supports UTF-8, and Python's str type can be encoded in UTF-8 also.
I had to add to the path the "é" as u"\u00E9" to simulate it coming out of the path preferences call, even if the call results in 'range compliant' symbols. The code you provided will display it corrupted with the two symbols you report. By adding "path.decode("utf-8")" it will display it as it should, the e-acute ("e accent aigu" in French). I'm spelling it out explicitly for anyone who might be seeing the é symbol as garbage in their particular browser, however unlikely.
Here's the code itself:
import c4d
import os
def main() :
path = c4d.storage.GeGetC4DPath(c4d.C4D_PATH_PREFS)
path = path.decode("utf-8") + u"\u00E9"
path = os.path.join(path, "StagePlugin/")
path = os.path.normpath(path)
print path
return
This link shows you another example in the Python documentation.
This link explains the encoding / decoding issue specifically.
I hope that helps solve the problem!
Joey Gaspe
SDK Support Engineer