代码之家  ›  专栏  ›  技术社区  ›  Narek

如何以编程方式编写RTF格式的unicode文本?

  •  0
  • Narek  · 技术社区  · 15 年前

    顺便说一句,我可以在.rtf文件中写一些文字,只需要用Word打开它。但在用unicode编写了一些文本之后,写字板显示文本是正确的。

    1 回复  |  直到 11 年前
        1
  •  1
  •   Michael Celey Luís Ledebour    12 年前

    以下是步骤:

    1. 创建一个名为.rtf的文件
    2. 在那里编写以下代码以生成包含UTF-8编码内容的RTF文件:

      {\rtf1\adeflang1025\ansi
      
      {\fonttbl
      {\f26\fbidi \froman\fcharset204\fprq2{\*\panose 010a0502050306030303}Sylfaen;}
      }
      
      {\rtlch\fcs1 \af31507 \ltrch\fcs0 \f26 \u<unicode number>\'3f\u<unicode number>\'3f\u<unicode number>\'3  A lot of other text and symbols 
      
      like this: + - *  _ }
      
      
      }
      

    例如:

    {\rtf1\adeflang1025\ansi
    
    {\fonttbl
    {\f26\fbidi \froman\fcharset204\fprq2{\*\panose 010a0502050306030303}Sylfaen;}
    }
    
    {\rtlch\fcs1 \af31507 \ltrch\fcs0 \f26 \u1329\'3f\u1330\'3f\u1331\'3f\u1332\'3f - these are first 4 latters of Armenian alphabet}
    
    }
    

    有关详细信息,请参阅UTF-8编码表 here . RTF规范是 here