normalize.html

来自「perl教程」· HTML 代码 · 共 500 行 · 第 1/2 页

HTML
500
字号
</dd>
</li>
<dt><strong><a name="item_checkfcd"><code>$result = checkFCD($string)</code></a></strong>

<dd>
<p>returns true (<code>1</code>) if <code>YES</code>; false (<code>empty string</code>) if <code>NO</code>.</p>
</dd>
</li>
<dt><strong><a name="item_checkfcc"><code>$result = checkFCC($string)</code></a></strong>

<dd>
<p>returns true (<code>1</code>) if <code>YES</code>; false (<code>empty string</code>) if <code>NO</code>;
<a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> if <code>MAYBE</code>.</p>
</dd>
<dd>
<p>If a string is not in FCD, it must not be in FCC.
So <a href="#item_checkfcc"><code>checkFCC($not_FCD_string)</code></a> should return <code>NO</code>.</p>
</dd>
</li>
<dt><strong><a name="item_check"><code>$result = check($form_name, $string)</code></a></strong>

<dd>
<p>returns true (<code>1</code>) if <code>YES</code>; false (<code>empty string</code>) if <code>NO</code>;
<a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> if <code>MAYBE</code>.</p>
</dd>
<dd>
<p>As <code>$form_name</code>, one of the following names must be given.</p>
</dd>
<dd>
<pre>
  'C'  or 'NFC'  for Normalization Form C  (UAX #15)
  'D'  or 'NFD'  for Normalization Form D  (UAX #15)
  'KC' or 'NFKC' for Normalization Form KC (UAX #15)
  'KD' or 'NFKD' for Normalization Form KD (UAX #15)</pre>
</dd>
<dd>
<pre>
  'FCD'          for &quot;Fast C or D&quot; Form  (UTN #5)
  'FCC'          for &quot;Fast C Contiguous&quot; (UTN #5)</pre>
</dd>
</li>
</dl>
<p><strong>Note</strong></p>
<p>In the cases of NFD, NFKD, and FCD, the answer must be
either <code>YES</code> or <code>NO</code>. The answer <code>MAYBE</code> may be returned
in the cases of NFC, NFKC, and FCC.</p>
<p>A <code>MAYBE</code> string should contain at least one combining character
or the like. For example, <code>COMBINING ACUTE ACCENT</code> has
the MAYBE_NFC/MAYBE_NFKC property.</p>
<p>Both <a href="#item_checknfc"><code>checkNFC(&quot;A\N{COMBINING ACUTE ACCENT}&quot;)</code></a>
and <a href="#item_checknfc"><code>checkNFC(&quot;B\N{COMBINING ACUTE ACCENT}&quot;)</code></a> will return <code>MAYBE</code>.
<code>&quot;A\N{COMBINING ACUTE ACCENT}&quot;</code> is not in NFC
(its NFC is <code>&quot;\N{LATIN CAPITAL LETTER A WITH ACUTE}&quot;</code>),
while <code>&quot;B\N{COMBINING ACUTE ACCENT}&quot;</code> is in NFC.</p>
<p>If you want to check exactly, compare the string with its NFC/NFKC/FCC.</p>
<pre>
    <span class="keyword">if</span> <span class="operator">(</span><span class="variable">$string</span> <span class="keyword">eq</span> <span class="variable">NFC</span><span class="operator">(</span><span class="variable">$string</span><span class="operator">))</span> <span class="operator">{</span>
        <span class="comment"># $string is exactly normalized in NFC;</span>
    <span class="operator">}</span> <span class="keyword">else</span> <span class="operator">{</span>
        <span class="comment"># $string is not normalized in NFC;</span>
    <span class="operator">}</span>
</pre>
<pre>
    <span class="keyword">if</span> <span class="operator">(</span><span class="variable">$string</span> <span class="keyword">eq</span> <span class="variable">NFKC</span><span class="operator">(</span><span class="variable">$string</span><span class="operator">))</span> <span class="operator">{</span>
        <span class="comment"># $string is exactly normalized in NFKC;</span>
    <span class="operator">}</span> <span class="keyword">else</span> <span class="operator">{</span>
        <span class="comment"># $string is not normalized in NFKC;</span>
    <span class="operator">}</span>
</pre>
<p>
</p>
<h2><a name="character_data">Character Data</a></h2>
<p>These functions are interface of character data used internally.
If you want only to get Unicode normalization forms, you don't need
call them yourself.</p>
<dl>
<dt><strong><a name="item_getcanon"><code>$canonical_decomposed = getCanon($codepoint)</code></a></strong>

<dd>
<p>If the character of the specified codepoint is canonically
decomposable (including Hangul Syllables),
returns the <strong>completely decomposed</strong> string canonically equivalent to it.</p>
</dd>
<dd>
<p>If it is not decomposable, returns <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a>.</p>
</dd>
</li>
<dt><strong><a name="item_getcompat"><code>$compatibility_decomposed = getCompat($codepoint)</code></a></strong>

<dd>
<p>If the character of the specified codepoint is compatibility
decomposable (including Hangul Syllables),
returns the <strong>completely decomposed</strong> string compatibility equivalent to it.</p>
</dd>
<dd>
<p>If it is not decomposable, returns <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a>.</p>
</dd>
</li>
<dt><strong><a name="item_getcomposite"><code>$codepoint_composite = getComposite($codepoint_here, $codepoint_next)</code></a></strong>

<dd>
<p>If two characters here and next (as codepoints) are composable
(including Hangul Jamo/Syllables and Composition Exclusions),
returns the codepoint of the composite.</p>
</dd>
<dd>
<p>If they are not composable, returns <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a>.</p>
</dd>
</li>
<dt><strong><a name="item_getcombinclass"><code>$combining_class = getCombinClass($codepoint)</code></a></strong>

<dd>
<p>Returns the combining class of the character as an integer.</p>
</dd>
</li>
<dt><strong><a name="item_isexclusion"><code>$is_exclusion = isExclusion($codepoint)</code></a></strong>

<dd>
<p>Returns a boolean whether the character of the specified codepoint
is a composition exclusion.</p>
</dd>
</li>
<dt><strong><a name="item_issingleton"><code>$is_singleton = isSingleton($codepoint)</code></a></strong>

<dd>
<p>Returns a boolean whether the character of the specified codepoint is
a singleton.</p>
</dd>
</li>
<dt><strong><a name="item_isnonstdecomp"><code>$is_non_starter_decomposition = isNonStDecomp($codepoint)</code></a></strong>

<dd>
<p>Returns a boolean whether the canonical decomposition
of the character of the specified codepoint
is a Non-Starter Decomposition.</p>
</dd>
</li>
<dt><strong><a name="item_iscomp2nd"><code>$may_be_composed_with_prev_char = isComp2nd($codepoint)</code></a></strong>

<dd>
<p>Returns a boolean whether the character of the specified codepoint
may be composed with the previous one in a certain composition
(including Hangul Compositions, but excluding
Composition Exclusions and Non-Starter Decompositions).</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="export">EXPORT</a></h1>
<p><a href="#item_nfc"><code>NFC</code></a>, <a href="#item_nfd"><code>NFD</code></a>, <a href="#item_nfkc"><code>NFKC</code></a>, <a href="#item_nfkd"><code>NFKD</code></a>: by default.</p>
<p><a href="#item_normalize"><code>normalize</code></a> and other some functions: on request.</p>
<p>
</p>
<hr />
<h1><a name="caveats">CAVEATS</a></h1>
<dl>
<dt><strong><a name="item_perl_27s_version_vs_2e_unicode_version">Perl's version vs. Unicode version</a></strong>

<dd>
<p>Since this module refers to perl core's Unicode database in the directory
<em>/lib/unicore</em> (or formerly <em>/lib/unicode</em>), the Unicode version of
normalization implemented by this module depends on your perl's version.</p>
</dd>
<dd>
<pre>
    perl's version         implemented Unicode version
       5.6.1                  3.0.1
       5.7.2                  3.1.0
       5.7.3                  3.1.1 (same normalized form as that of 3.1.0)
       5.8.0                  3.2.0
     5.8.1-5.8.3              4.0.0
     5.8.4-5.8.6 (latest)     4.0.1 (same normalized form as that of 4.0.0)</pre>
</dd>
</li>
<dt><strong><a name="item_correction_of_decomposition_mapping">Correction of decomposition mapping</a></strong>

<dd>
<p>In older Unicode versions, a small number of characters (all of which are
CJK compatibility ideographs as far as they have been found) may have
an erroneous decomposition mapping (see <em>NormalizationCorrections.txt</em>).
Anyhow, this module will neither refer to <em>NormalizationCorrections.txt</em>
nor provide any specific version of normalization. Therefore this module
running on an older perl with an older Unicode database may use
the erroneous decomposition mapping blindly conforming to the Unicode database.</p>
</dd>
</li>
<dt><strong><a name="item_revised_definition_of_canonical_composition">Revised definition of canonical composition</a></strong>

<dd>
<p>In Unicode 4.1.0, the definition D2 of canonical composition (which
affects NFC and NFKC) has been changed (see Public Review Issue #29
and recent UAX #15). This module has used the newer definition
since the version 0.07 (Oct 31, 2001).
This module does not support normalization according to the older
definition, even if the Unicode version implemented by perl is
lower than 4.1.0.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>SADAHIRO Tomoyuki &lt;<a href="mailto:SADAHIRO@cpan.org">SADAHIRO@cpan.org</a>&gt;</p>
<p><code>Copyright(C)</code> 2001-2005, SADAHIRO Tomoyuki. Japan. All rights reserved.</p>
<p>This module is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<dl>
<dt><strong><a name="item_http_3a_2f_2fwww_2eunicode_2eorg_2freports_2ftr15_"><a href="http://www.unicode.org/reports/tr15/">http://www.unicode.org/reports/tr15/</a></a></strong>

<dd>
<p>Unicode Normalization Forms - UAX #15</p>
</dd>
</li>
<dt><strong><a name="item_http_3a_2f_2fwww_2eunicode_2eorg_2fpublic_2funidat"><a href="http://www.unicode.org/Public/UNIDATA/DerivedNormalizationProps.txt">http://www.unicode.org/Public/UNIDATA/DerivedNormalizationProps.txt</a></a></strong>

<dd>
<p>Derived Normalization Properties</p>
</dd>
</li>
<dt><strong><a href="http://www.unicode.org/Public/UNIDATA/NormalizationCorrections.txt">http://www.unicode.org/Public/UNIDATA/NormalizationCorrections.txt</a></strong>

<dd>
<p>Normalization Corrections</p>
</dd>
</li>
<dt><strong><a name="item_http_3a_2f_2fwww_2eunicode_2eorg_2freview_2fpr_2d2"><a href="http://www.unicode.org/review/pr-29.html">http://www.unicode.org/review/pr-29.html</a></a></strong>

<dd>
<p>Public Review Issue #29: Normalization Issue</p>
</dd>
</li>
<dt><strong><a name="item_http_3a_2f_2fwww_2eunicode_2eorg_2fnotes_2ftn5_2f"><a href="http://www.unicode.org/notes/tn5/">http://www.unicode.org/notes/tn5/</a></a></strong>

<dd>
<p>Canonical Equivalence in Applications - UTN #5</p>
</dd>
</li>
</dl>

</body>

</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?