Jon*_*nde 3 javascript html5 canvas
有没有办法在HTML5画布上打印希腊字母?我试过使用html实体名称和数字,就像这样
canvas2.cx.fillText("ξ", 50, 50);
Run Code Online (Sandbox Code Playgroud)
和
canvas2.cx.fillText("ξ", 50, 50);
Run Code Online (Sandbox Code Playgroud)
但它只是字面上打印出来,因为画布不知道解释这些符号.
Den*_*ret 11
只需使用UTF-8即可.
您不必转义字符以在HTML或Canvas中编写它们.
在文档中使用正确的标题:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF8">
Run Code Online (Sandbox Code Playgroud)
如果要将JavaScript源限制为ASCII,但仍在字符串中包含非ASCII字符,则可以使用Unicode转义序列:(小xi的代码点为U + 03BE):
canvas2.cx.fillText("\u03be", 50, 50);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8196 次 |
| 最近记录: |