モジュール:サンドボックス/likibp/GraphemeSplitter/GetGraphemeBreakProperty
表示
モジュールの解説[作成]
--[[
GetGraphemeBreakProperty is a module designed for the Scribunto extension to MediaWiki.
This module is a port of the original source found at:
https://github.com/ufcpp/GraphemeSplitter
The source code is licensed under the MIT license:
https://opensource.org/licenses/MIT
Note: This source code, when used on or obtained from a wiki site operated by the Wikimedia Foundation,
is additionally licensed under the Creative Commons Attribution-ShareAlike License:
https://creativecommons.org/licenses/by-sa/4.0/deed
--]]
require('strict')
local checkType = require('libraryUtil').checkType
local character = {}
--local graphemeBreakProperties = mw.loadData("Module:GraphemeSplitter/GraphemeBreakPropertyV15")
local graphemeBreakProperties = mw.loadData("モジュール:サンドボックス/likibp/GraphemeSplitter/GraphemeBreakPropertyV15")
---The function returns the grapheme break property of the character corresponding to the given `codePoint`.
---@param codePoint number: Unicode code points
---@return string: Grapheme break property
function character.getGraphemeBreakProperty(codePoint)
checkType('getGraphemeBreakProperty', 1, codePoint, 'number')
for _, item in ipairs(graphemeBreakProperties) do
local startRange, endRange = item.range[1], item.range[2]
if startRange <= codePoint and codePoint <= endRange then
return item.value
end
end
return "Other" -- default value
end
return character