如何将Unicode符号添加到提交按钮

问题描述:

我想在SubmitField的文本中添加一个unicode.

I would like to add a unicode to the text of a SubmitField.

例如,代码

submit = SubmitField('✉ Send') 

不起作用.我该如何更改以显示此信封unicode?​​ p>

does not work. How can I change that to show this envelope unicode?

只需在\uhhhh转义序列中使用unicode代码点,就无需使用HTML转义:

Just use the unicode codepoint in a \uhhhh escape sequence, there is no need to use HTML escapes:

submit = SubmitField('\u2709 Send')

甚至是代码点本身:

submit = SubmitField('✉ Send')

产生的字符串值完全相同.

The string value produced is exactly the same.

用引号引起来的标签可以确保正确处理HTML,因此标签值中的所有&字符都被编码为&,从而破坏了✉引用.

The label is quoted to ensure proper handling in HTML, so any & characters in the label value are encoded to &, breaking your ✉ reference.