【问题标题】:How can I get the unicode values of Bullets in a word document如何在 word 文档中获取项目符号的 unicode 值
【发布时间】:2015-12-29 11:32:36
【问题描述】:

我正在开发一个 Web 应用程序,不希望用户输入一些会造成问题的无效字符。

导致问题的一个这样的字符是 MS word 中的 diamond bullet 但要删除该字符,我需要知道该字符的 Unicode,以便我可以将其包含在无效的 Python 正则表达式中字符as suggested here

textString = some value which need to be checked for invalid characters
pattern = some regular expression for invalid characters
if pattern.search(textString):
    print 'Invalid characters found'
else:
    print 'Valid string'

我找到了类似的解决方案here,但这不适用于子弹。

请大家帮我解决这个问题。

【问题讨论】:

  • 你试过搜索“unicode bullet”吗?
  • @mvm,我试过了!我找到了 U+2022
  • @Plasma 我也找到了这个,但我需要搜索那个特定项目符号的 Unicode 值吗?
  • 如果你知道而不是投反对票,请给我提示
  • 如果您知道您不想允许哪些字符(或者相反,您想要允许的唯一字符),一种方法可能是在 unicode 范围上使用正则表达式。有关如何使用 unicode 范围的信息,请参阅this 答案。编辑:另外,this 是关于一般方法的讨论。

标签: python regex ms-word


【解决方案1】:

使用无效字符创建 Word 文档。 (不要使用子弹制作图标,使用 Insert->symbol->symbol 浏览器并从地图中选择)。

解压。

unzip myDoc.docx

并在能够读取 unicode 字符的编辑器中打开 word/document.xml 文件。在这里,我使用 xmllintmore 作为快速而肮脏的示例。我不知道你在说哪个子弹,但我在这里尝试的那个显示 U+F075:

xmllint --format word/document.xml | more

<w:r w:rsidR="00A50B17" w:rsidRPr="00E62AD7">
    <w:rPr>
      <w:rFonts w:ascii="Wingdings" w:hAnsi="Wingdings"/>
      <w:color w:val="000000"/>
    </w:rPr>
    <w:t><U+F075></w:t>
  </w:r>

然后对于所有 unicode 字符,将它们放入您的脚本中。

【讨论】:

    猜你喜欢
    • 2011-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-06
    • 2020-12-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多