<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><p>This specification defines how to implement
general-purpose Kana transliterators.</p><section><h1>Conformance</h1><p>A conforming implementation
<MUST xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">MUST</MUST> use 
the steps to
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">convert a string into Katakana</anchor>
to implement Hiragana to Katakana conversions,
or
the steps to
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">convert a string into Hiragana</anchor>
to implement Katakana to Hiragana conversions.</p></section><section><h1>Hiragana to Katakana</h1><p>To <dfn>convert a string into Katakana</dfn> with string <var>input</var>,
run these steps:</p><figure class="steps"><ol><li>Return the result of running the steps to
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">transliterate a string</anchor> <var>input</var> with the <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Hiragana to Katakana table</anchor>.</li></ol></figure></section><section><h1>Katakana to Hiragana</h1><p>To <dfn>convert a string into Hiragana</dfn> with string <var>input</var>,
run these steps:</p><figure class="steps"><ol><li>Return the result of running the steps to
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">transliterate a string</anchor> <var>input</var> with the <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Katakana to Hiragana table</anchor>.</li></ol></figure></section><section><h1>Normalization</h1><p>To <dfn>normalize a Kana string</dfn> <var>input</var>, run these steps:</p><figure class="steps"><ol><li>Let <var>output</var> be the empty <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">string</anchor>.</li><li>Let <var>length</var> be the <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">length</anchor> of <var>input</var>.</li><li>Let <var>mapping table</var> be the <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Normalization table</anchor>.</li><li>Let <var>i</var> be zero.</li><li><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">While</anchor> <var>i</var> is less than <var>length</var>:<ol><li>Let <var>char</var> be <var>i</var>th <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">code point</anchor> within <var>input</var>.</li><li>Let <var>mark</var> be the empty <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">string</anchor>.</li><li>If <var>i</var> + 1 is less than <var>length</var>:<ol><li>Set <var>mark</var> to (<var>i</var> + 1)th <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">code point</anchor> within <var>input</var>.</li></ol></li><li>If <var>mark</var> is not the empty <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">string</anchor> and 
<var>mapping table</var> [ <var>char</var> followed by <var>mark</var> ] <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">exists</anchor>:<ol><li><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Append<title xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">append</title></anchor> <var>mapping table</var> [ <var>char</var> followed by <var>mark</var> ] to <var>output</var>.</li><li>Increment <var>i</var> by two.</li></ol></li><li>Otherwise, if <var>mapping table</var> [ <var>char</var> ] <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">exists</anchor>:<ol><li><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Append<title xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">append</title></anchor> <var>mapping table</var> [ <var>char</var> ] to <var>output</var>.</li><li>Increment <var>i</var> by one.</li></ol></li><li>Otherwise:<ol><li><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Append<title xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">append</title></anchor> <var>char</var> to <var>output</var>.</li><li>Increment <var>i</var> by one.</li></ol></li></ol></li><li>Return <var>output</var>.</li></ol></figure></section><section><h1>Algorithm</h1><p>To <dfn>transliterate a string</dfn>
<var>input</var> with <var>mapping table</var>,
run these steps:</p><figure class="steps"><ol><li>Let <var>output</var> be the empty <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">string</anchor>.</li><li><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">For each</anchor> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">code point</anchor> <var>char</var> in <var>input</var>:<ol><li>If <var>mapping table</var> [ <var>char</var> ] <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">exists</anchor>:<ol><li><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Append<title xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">append</title></anchor> <var>mapping table</var> [ <var>char</var> ] to <var>output</var>.</li></ol></li><li>Otherwise:<ol><li><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Append<title xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">append</title></anchor> <var>char</var> to <var>output</var>.</li></ol></li></ol></li><li>Return <var>output</var>.</li></ol></figure><comment-p xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">A <var xmlns="http://www.w3.org/1999/xhtml">mapping table</var> [ <var xmlns="http://www.w3.org/1999/xhtml">char</var> ] value can have more than one
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">code points<title xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">code point</title></anchor>.</comment-p></section><section><h1>Tables</h1><p>Tables referenced from this specification are defined in the <code>maps.json</code>
data file 
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/manakai/data-chars/blob/master/data/maps.json">https://github.com/manakai/data-chars/blob/master/data/maps.json</anchor-external>
(documentation: <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/manakai/data-chars/blob/master/doc/maps.txt">https://github.com/manakai/data-chars/blob/master/doc/maps.txt</anchor-external>),
which is a normative part of this specification.</p><p>The JSON data file contains several mapping tables, identified by
a name, containing entries from code points to code points.
For the purpose of this specification, 
they are considered as <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">maps<title xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">map</title></anchor> of 
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">string</anchor> to <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">string</anchor> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">entries<title xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">entry</title></anchor>
with following names:</p><figure class="table"><dl><dt>json</dt><dd>Name in JSON data file</dd><dt>this</dt><dd>Name in this specification</dd></dl><dl><dt>json</dt><dd><code>kana:h2k</code></dd><dt>this</dt><dd><dfn>Hiragana to Katakana table</dfn></dd></dl><dl><dt>json</dt><dd><code>kana:k2h</code></dd><dt>this</dt><dd><dfn>Katakana to Hiragana table</dfn></dd></dl><dl><dt>json</dt><dd><code>kana:normalization</code></dd><dt>this</dt><dd><dfn>Normalization table</dfn></dd></dl></figure><comment-p xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">Any other mapping tables in the JSON data file are not used by this specification.</comment-p><p>These tables will be updated when new Kana characters are added to
the <cite>Unicode Standard</cite>.  Implementations <SHOULD xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">SHOULD</SHOULD>
be prepared for updating their tables.</p></section><section><h1>References</h1><p>This specification depends on the <cite>Infra Standard</cite>
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://infra.spec.whatwg.org/">https://infra.spec.whatwg.org/</anchor-external>.
The terms
<dfn>for each<title xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">For each</title></dfn>,
<dfn>while<title xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">While</title></dfn>,
<dfn>code point</dfn>,
<dfn>length</dfn>,
<dfn>string</dfn>,
<dfn>append</dfn>,
<dfn>ordered map<title xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">map</title></dfn>,
<dfn>entry</dfn>,
and
<dfn>exists</dfn>
are defined by the <cite>Infra Standard</cite>.</p></section><section><h1>Test data</h1><p><i>This section is non-normative.</i></p><p>There are test data:</p><ul><li><anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/manakai/data-chars/blob/master/data/tests/kana-tokana.json">https://github.com/manakai/data-chars/blob/master/data/tests/kana-tokana.json</anchor-external></li><li><anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/manakai/data-chars/blob/master/data/tests/kana-normalize.json">https://github.com/manakai/data-chars/blob/master/data/tests/kana-normalize.json</anchor-external></li><li>Documentation:
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/manakai/data-chars/blob/master/data/tests/kana-tests.txt">https://github.com/manakai/data-chars/blob/master/data/tests/kana-tests.txt</anchor-external></li></ul></section><section><h1>License</h1><p>Per CC0 <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://creativecommons.org/publicdomain/zero/1.0/">https://creativecommons.org/publicdomain/zero/1.0/</anchor-external>, to the extent possible under law, the author of this specification has waived all copyright and related or neighboring rights to this specification.</p></section><section><h1>Notes</h1><p><i>This section is non-normative.</i></p><p>See <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">平仮名と片仮名</anchor> for rationale.</p></section></body></html>