在 Microsoft Visual Studio 中创建的标记文件自动以 Unicode UTF-8 的文件格式保存,这意味着大多数特殊字符(如重音符号)都会正确编码。 不过,有一组常用特殊字符的处理方式有所不同。 这些特殊字符遵循World Wide Web Consortium (W3C) XML 编码标准。
下表显示了对这组特殊字符进行编码所用的语法:
| 字符 | 语法 | 说明 | 
|---|---|---|
| < | < | 小于号。 | 
| > | > | 大于号。 | 
| & | & | “and”符。 | 
| " | " | 双引号。 | 
| .gif) 注意 | 
|---|
| 如果使用文本编辑器(如 Windows 记事本)创建标记文件,则必须以 Unicode UTF-8 文件格式保存文件以保留任何编码的特殊字符。 | 
下面的示例演示在创建标记时如何在文本中使用特殊字符。
示例
<!-- Display special characters that require special encoding: < > & " -->
<TextBlock>
  <    <!-- Less than symbol -->
  >    <!-- Greater than symbol -->
  &   <!-- Ampersand symbol -->
  "  <!-- Double quote symbol -->
</TextBlock>
<!-- Display miscellaneous special characters -->
<TextBlock>
  Cæsar   <!-- AE dipthong symbol -->
  © 2006  <!-- Copyright symbol -->
  Español <!-- Tilde symbol -->
  ¥       <!-- Yen symbol -->
</TextBlock>