Unicode characters
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/11/2012 at 09:24, xxxxxxxx wrote:
In Python, you just need to put 'u' before the string literal: u"\u00C5land (Finland)". Strings in CINEMA fully use Unicode characters.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/11/2012 at 10:39, xxxxxxxx wrote:
Thanks.
As always a clear and fast answer! -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/11/2012 at 04:24, xxxxxxxx wrote:
Sorry, not yet completely clear.
The following works:
self.AddChild(MY_1SELCONTINENT, CUSTOM, u"\u00C5land (Finland)")This works too:
finland = u"\u00C5land (Finland)"
self.AddChild(MY_1SELCONTINENT, CUSTOM, finland)This, of course, does not work:
self.AddChild(MY_1SELCONTINENT, CUSTOM, ufinland)What I want.
I read in all variables, for example finland = "\u00C5land (Finland)"
How to display this in my GUI? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/11/2012 at 05:51, xxxxxxxx wrote:
Originally posted by xxxxxxxx
This, of course, does not work:
self.AddChild(MY_1SELCONTINENT, CUSTOM, ufinland)How do you read ufinland string variable? I think you could use unicode() Python built-in function.
EDIT: Ok, I see you have finland but adding 'u' before doesn't do anything because it only works with string literals. ufinland is a new variable. So you should call unicode(finland) instead.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/11/2012 at 08:34, xxxxxxxx wrote:
Sorry, that does not work.
finland = "\u00C5land (Finland)"
self.AddChild(MY_1SELCONTINENT, CUSTOM, unicode(finland))It display in the field: \u00C5land (Finland)
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/11/2012 at 10:00, xxxxxxxx wrote:
Do you read Unicode strings from a file? You should then decode them to utf-8:
input = open('unicode.txt') finland = input.read() print finland.decode('utf8')
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/11/2012 at 13:27, xxxxxxxx wrote:
I tried following script, but it does not work it still displays:"\u00C5land (Finland)" and not the first unicode character.
coding: UTF-8
import c4d
from c4d import guiunicode.txt contains one line:
"\u00C5land (Finland)"
def main() :
input = open('unicode.txt')
finland = input.read()
print "finland utf8: ", finland.decode('utf8')
gui.MessageDialog(finland)if __name__=='__main__':
main() -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/11/2012 at 00:17, xxxxxxxx wrote:
Originally posted by xxxxxxxx
I tried following script, but it does not work it still displays:"\u00C5land (Finland)" and not the first unicode character.
unicode.txt contains one line:
"\u00C5land (Finland)"
This is because the unicode file should contain "Ã…land (Finland)", not "\u00C5land (Finland)".
Here's the code I used:# coding: UTF-8 # If you specify UTF-8 encoding, you then don't need to replace Ã… by \u00C5 in your code # See string literal below import c4d from c4d import gui def WriteUnicode() : utf8_string = u"Ã…land (Finland)".encode('utf8') output = open('unicode.txt', 'w') output.write(utf8_string) output.close() def ReadUnicode() : input = open('unicode.txt') utf8_string = input.read() print utf8_string.decode('utf8') def main() : WriteUnicode() ReadUnicode() if __name__=='__main__': main()
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/11/2012 at 02:08, xxxxxxxx wrote:
Ok, clear.
However, the input I read from the files uses "\u00C5land (Finland)"
I use the Cinema 4d file \CINEMA 4D R13\modules\advanced render\sky\res\cities.csv
So, how to read that file and display it properly? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/11/2012 at 04:35, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Ok, clear.
However, the input I read from the files uses "\u00C5land (Finland)"
I use the Cinema 4d file \CINEMA 4D R13\modules\advanced render\sky\res\cities.csv
So, how to read that file and display it properly?Ok, I finally found the solution .
We have to decode the string with unicode_escape codec to produce a string that is suitable as raw Unicode literal in Python source code (u'' does this directly with literals).
Here's the code:finland = "\u00C5land (Finland)" print finland # Stored as '\\u00C5land' (double escape) print finland.decode('unicode_escape')
And this code is the same than:
finland = u"\u00C5land (Finland)" print finland
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/11/2012 at 07:26, xxxxxxxx wrote:
Thank you very much.
Appreciate the patience and willing to solve it.