Accents / special characters (e.g. -) in verbose_name or help_text?

How to use letters with accents or special characters, for example - in verbose_name or help_text?

+4
source share
3 answers

include this at the beginning of the file:

# -*- coding: utf-8 -*- 

and then use this:

 u'áéíóú' 
+7
source

I have done this:

 import os, sys #encoding= utf-8 

thanks

0
source

@ diegueus9 has the correct answer for using raw Unicode characters in the source file. Use any characters you like while you declare the encoding according to the instructions in PEP263 . However, it might be easier for you to use just a few special characters: declare the string as Unicode with the u prefix and use the dot character code. The following are equivalent ways to write "-":

 help_text=u'\xF1 \u00F1 \U000000F1' 

When it comes to actually finding a code point for a character ... it's a little trickier. Windows has a useful character map utility. gucharmap is similar. charts on unicode.org provide special pdf files in alphabetical order that you can execute. Does anyone know an easier way?

0
source

All Articles