<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://naija.elizia.net/index.php?action=history&amp;feed=atom&amp;title=Module%3ADonn%C3%A9es_Unicode</id>
	<title>Module:Données Unicode - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://naija.elizia.net/index.php?action=history&amp;feed=atom&amp;title=Module%3ADonn%C3%A9es_Unicode"/>
	<link rel="alternate" type="text/html" href="http://naija.elizia.net/index.php?title=Module:Donn%C3%A9es_Unicode&amp;action=history"/>
	<updated>2026-10-19T10:11:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.0-rc.0</generator>
	<entry>
		<id>http://naija.elizia.net/index.php?title=Module:Donn%C3%A9es_Unicode&amp;diff=254&amp;oldid=prev</id>
		<title>Root: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://naija.elizia.net/index.php?title=Module:Donn%C3%A9es_Unicode&amp;diff=254&amp;oldid=prev"/>
		<updated>2020-08-07T13:08:59Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:08, 7 August 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Root</name></author>
	</entry>
	<entry>
		<id>http://naija.elizia.net/index.php?title=Module:Donn%C3%A9es_Unicode&amp;diff=253&amp;oldid=prev</id>
		<title>Mediawiki&gt;Darmo117: trad doc ; refactor</title>
		<link rel="alternate" type="text/html" href="http://naija.elizia.net/index.php?title=Module:Donn%C3%A9es_Unicode&amp;diff=253&amp;oldid=prev"/>
		<updated>2020-06-02T18:56:51Z</updated>

		<summary type="html">&lt;p&gt;trad doc ; refactor&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local m_params = require(&amp;quot;Module:paramètres&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
---------------------------------&lt;br /&gt;
-- Functions for other modules --&lt;br /&gt;
---------------------------------&lt;br /&gt;
&lt;br /&gt;
-- Data loading functions --&lt;br /&gt;
&lt;br /&gt;
--- Returns the list of all Unicode blocks.&lt;br /&gt;
--- @return table&lt;br /&gt;
function p.getBlocks()&lt;br /&gt;
  return mw.loadData(&amp;quot;Module:données Unicode/data/blocks&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the list of all Unicode scripts.&lt;br /&gt;
--- @return table&lt;br /&gt;
function p.getScripts()&lt;br /&gt;
  return mw.loadData(&amp;quot;Module:données Unicode/data/scripts&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the list of all Unicode script ranges.&lt;br /&gt;
--- @return table&lt;br /&gt;
function p.getScriptRanges()&lt;br /&gt;
  -- Loaded with require() instead of mw.loadData() as the returned table&lt;br /&gt;
  -- has tables as keys.&lt;br /&gt;
  return require(&amp;quot;Module:données Unicode/data/script ranges&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Block-related functions --&lt;br /&gt;
&lt;br /&gt;
--- Returns the Unicode block that has the given lowest codepoint.&lt;br /&gt;
--- @param lowerCodepoint number The lowest codepoint of the block.&lt;br /&gt;
--- @return table|nil The block or nil if none were found.&lt;br /&gt;
function p.getBlock(lowerCodepoint)&lt;br /&gt;
  return p.getBlocks()[lowerCodepoint]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the Unicode block that contains the given character.&lt;br /&gt;
--- Throws an error if zero or more than 1 characters were given.&lt;br /&gt;
--- @param char string The character.&lt;br /&gt;
--- @return table|nil The block or nil if the character doesn’t belong to any block.&lt;br /&gt;
function p.getBlockForChar(char)&lt;br /&gt;
  local len = mw.ustring.len(char)&lt;br /&gt;
  if len ~= 1 then&lt;br /&gt;
    error(mw.ustring.format(&amp;#039;Un seul caractère attendu, %d donnés (&amp;quot;%s&amp;quot;)&amp;#039;, len, char))&lt;br /&gt;
  end&lt;br /&gt;
  local code = mw.ustring.codepoint(char)&lt;br /&gt;
&lt;br /&gt;
  for _, block in pairs(p.getBlocks()) do&lt;br /&gt;
    if block.lower &amp;lt;= code and code &amp;lt;= block.upper then&lt;br /&gt;
      return block&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Script-related functions --&lt;br /&gt;
&lt;br /&gt;
--- Returns the Unicode script for the given code.&lt;br /&gt;
--- @param code string The script’s code.&lt;br /&gt;
--- @return table|nil The script or nil if none were found.&lt;br /&gt;
function p.getScript(code)&lt;br /&gt;
  return p.getScripts()[code]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the Unicode script for the given character.&lt;br /&gt;
--- Throws an error if zero or more than 1 characters were given.&lt;br /&gt;
--- @param char string The character.&lt;br /&gt;
--- @return table|nil The script or nil if the character doesn’t belong to any block.&lt;br /&gt;
function p.getScriptForChar(char)&lt;br /&gt;
  local len = mw.ustring.len(char)&lt;br /&gt;
  if len ~= 1 then&lt;br /&gt;
    error(mw.ustring.format(&amp;quot;Un seul caractère attendu, %d donnés&amp;quot;, len))&lt;br /&gt;
  end&lt;br /&gt;
  local code = mw.ustring.codepoint(char)&lt;br /&gt;
  local scripts = p.getScripts()&lt;br /&gt;
&lt;br /&gt;
  for range, script_code in pairs(p.getScriptRanges()) do&lt;br /&gt;
    if range[1] &amp;lt;= code and code &amp;lt;= range[2] then&lt;br /&gt;
      return scripts[script_code]&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  return scripts[&amp;quot;Unknown&amp;quot;]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the Unicode script for the given text.&lt;br /&gt;
--- If the text contains character from several scripts other than&lt;br /&gt;
--- Common or Inherited, the returned script is Common.&lt;br /&gt;
--- @param text string The text.&lt;br /&gt;
--- @return table The script.&lt;br /&gt;
function p.getScriptForText(text)&lt;br /&gt;
  local inheritedFound = false&lt;br /&gt;
  local commonFound = false&lt;br /&gt;
  local res&lt;br /&gt;
&lt;br /&gt;
  for i = 1, mw.ustring.len(text) do&lt;br /&gt;
    local c = mw.ustring.sub(text, i, i)&lt;br /&gt;
    local script = p.getScriptForChar(c)&lt;br /&gt;
    local name = script.code&lt;br /&gt;
&lt;br /&gt;
    if not commonFound and name == &amp;quot;Common&amp;quot; then&lt;br /&gt;
      commonFound = true&lt;br /&gt;
    elseif not inheritedFound and name == &amp;quot;Inherited&amp;quot; then&lt;br /&gt;
      inheritedFound = true&lt;br /&gt;
    elseif name ~= &amp;quot;Common&amp;quot; and name ~= &amp;quot;Inherited&amp;quot; then&lt;br /&gt;
      if res == nil or res.code == &amp;quot;Unknown&amp;quot; then&lt;br /&gt;
        res = script&lt;br /&gt;
      elseif res ~= nil and script.code ~= &amp;quot;Unknown&amp;quot; and script.code ~= res.code then&lt;br /&gt;
        return p.getScript(&amp;quot;Common&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  if res == nil then&lt;br /&gt;
    if inheritedFound then&lt;br /&gt;
      return p.getScript(&amp;quot;Inherited&amp;quot;)&lt;br /&gt;
    elseif commonFound then&lt;br /&gt;
      return p.getScript(&amp;quot;Common&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  return res&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Indicates wether the given text is in the given Unicode script.&lt;br /&gt;
--- @param text string The text.&lt;br /&gt;
--- @param scriptCode string The scripts code.&lt;br /&gt;
--- @return boolean True if the code exists and the text is in this script,&lt;br /&gt;
---                 false otherwise.&lt;br /&gt;
function p.textHasScript(text, scriptCode)&lt;br /&gt;
  local script = p.getScript(scriptCode)&lt;br /&gt;
  return script ~= nil and p.getScriptForText(text).code == script.code&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local directionToCss = {&lt;br /&gt;
  [&amp;quot;lr&amp;quot;] = &amp;quot;horizontal-tb&amp;quot;,&lt;br /&gt;
  [&amp;quot;rl&amp;quot;] = &amp;quot;horizontal-tb&amp;quot;,&lt;br /&gt;
  [&amp;quot;tb&amp;quot;] = &amp;quot;vertical-lr&amp;quot;,&lt;br /&gt;
  [&amp;quot;i&amp;quot;] = &amp;quot;inherit&amp;quot;,&lt;br /&gt;
  [&amp;quot;m&amp;quot;] = &amp;quot;inherit&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
--- Sets the writing direction for the given text, based on its Unicode script,&lt;br /&gt;
--- by inserting it inside a span tag.&lt;br /&gt;
--- @param text string The text.&lt;br /&gt;
--- @return string The text, included in a span tag with the writing-mode CSS rule.&lt;br /&gt;
function p.setWritingDirection(text)&lt;br /&gt;
  local script = p.getScriptForText(text)&lt;br /&gt;
  return mw.ustring.format(&amp;#039;&amp;lt;span style=&amp;quot;writing-mode:%s&amp;quot;&amp;gt;%s&amp;lt;/span&amp;gt;&amp;#039;, directionToCss[script.direction or &amp;quot;i&amp;quot;], text)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-----------------------------&lt;br /&gt;
-- Functions for templates --&lt;br /&gt;
-----------------------------&lt;br /&gt;
&lt;br /&gt;
--- Returns the wikitext for template [[Modèle:Bloc Unicode]].&lt;br /&gt;
---  frame.args[1] (int, optional): The lower bound of the Unicode block&lt;br /&gt;
---   (decimal or hexadecimal with “0x” prefix).&lt;br /&gt;
---   If undefined, the code will be extracted from the page’s title.&lt;br /&gt;
--- @return string The template’s wikicode.&lt;br /&gt;
function p.blockReference(frame)&lt;br /&gt;
  local args = m_params.process(frame.args, {&lt;br /&gt;
    [1] = { type = m_params.INT },&lt;br /&gt;
  })&lt;br /&gt;
  local blockCode = args[1]&lt;br /&gt;
  local block&lt;br /&gt;
&lt;br /&gt;
  if blockCode ~= nil then&lt;br /&gt;
    block = p.getBlock(blockCode)&lt;br /&gt;
  else&lt;br /&gt;
    block = p.getBlockForChar(mw.title.getCurrentTitle().text)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  if block ~= nil then&lt;br /&gt;
    return mw.ustring.format(&amp;quot;Unicode, Inc., &amp;#039;&amp;#039;[%s %s]&amp;#039;&amp;#039;, The Unicode Standard, version %s, %d&amp;quot;,&lt;br /&gt;
        block.url, block.name.en, block.version, block.year)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  error(&amp;quot;Bloc Unicode incorrect&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Sets the writing direction for the given text, based on its Unicode script,&lt;br /&gt;
--- by inserting it inside a span tag.&lt;br /&gt;
---  frame.args[1] (string): The text.&lt;br /&gt;
--- @return string The text, included in a span tag with the writing-mode CSS rule.&lt;br /&gt;
function p.writingDirection(frame)&lt;br /&gt;
  local args = m_params.process(frame.args, {&lt;br /&gt;
    [1] = { required = true, allow_empty = true },&lt;br /&gt;
  })&lt;br /&gt;
  return p.setWritingDirection(args[1])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the Unicode codepoint of the given character.&lt;br /&gt;
--- Throws an error if zero or more than 1 characters were given.&lt;br /&gt;
---  frame.args[1] (string, only one character): The character.&lt;br /&gt;
---  frame.args[2] (boolean, default = false) : Indicates wether the returned codepoint&lt;br /&gt;
---   will be in hexadecimal.&lt;br /&gt;
--- @return string|number The character’s codepoint without the “0x” prefix if it is in hexadecimal.&lt;br /&gt;
function p.codepoint(frame)&lt;br /&gt;
  local args = m_params.process(frame.args, {&lt;br /&gt;
    [1] = {&lt;br /&gt;
      required = true,&lt;br /&gt;
      checker = function(value)&lt;br /&gt;
        return mw.ustring.len(value) == 1&lt;br /&gt;
      end,&lt;br /&gt;
    },&lt;br /&gt;
    [&amp;quot;hexa&amp;quot;] = { type = m_params.BOOLEAN, default = false },&lt;br /&gt;
  })&lt;br /&gt;
  local char = args[1]&lt;br /&gt;
  local isHex = args[&amp;quot;hexa&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
  local code = mw.ustring.codepoint(char)&lt;br /&gt;
  if isHex then&lt;br /&gt;
    return string.format(&amp;quot;%04X&amp;quot;, code)&lt;br /&gt;
  end&lt;br /&gt;
  return code&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the character with the given Unicode codepoint.&lt;br /&gt;
--- Throws an error if the codepoint is invalid.&lt;br /&gt;
---  frame.args[1] (int): The codepoint.&lt;br /&gt;
--- @return string The character.&lt;br /&gt;
function p.character(frame)&lt;br /&gt;
  local args = m_params.process(frame.args, {&lt;br /&gt;
    [1] = { required = true, type = m_params.INT },&lt;br /&gt;
  })&lt;br /&gt;
  local code = tonumber(args[1])&lt;br /&gt;
&lt;br /&gt;
  if code ~= nil then&lt;br /&gt;
    local success, char = pcall(mw.ustring.char, code)&lt;br /&gt;
    if success then&lt;br /&gt;
      return char&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  error(&amp;quot;Point de code incorrect&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Mediawiki&gt;Darmo117</name></author>
	</entry>
</feed>