본문으로 이동

미디어위키 1.45 안정화가 거의 끝났습니다. 다만 Flow 확장 기능 관련 이슈가 있어서 대체하는 작업을 수행할 계획입니다.

  1. 큰숲백과:청사진에서 위키 발전의 대략적인 방향성을 제시했습니다. 의견이 있으신 분은 큰숲백과토론:청사진에서 의견을 남겨주시면 좋겠습니다.
  2. 기능상의 오류로 지원하지 않고 있는 기능에 대해서는 큰숲백과토론:이슈 트래커에 요약했습니다. 참고하시기 바랍니다.
  3. 데이터베이스 덤프 받고싶으신 분은 큰숲백과 가입 후에 사용자토론:Bigforest에 의견 남겨주시면 ftp 주소, 계정, 비밀번호를 특수:EmailUser를 통해서 공개할 예정입니다.

모듈:Unicode: 두 판 사이의 차이

큰숲백과, 나무를 보지 말고 큰 숲을 보라.
편집 요약 없음
편집 요약 없음
6번째 줄: 6번째 줄:
---@param code string string: U+ABCD
---@param code string string: U+ABCD
function p.tochar(code)
function p.tochar(code)
return ustring.char(tonumber(code:gsub(" ", ""):gsub("[Uu][+]", "0x"), 16))
    return ustring.char(tonumber(code:gsub(" ", ""):gsub("[Uu][+]", "0x"), 16))
end
end


14번째 줄: 14번째 줄:
---@return string
---@return string
function p.tounicode(frame)
function p.tounicode(frame)
return 'U+' .. string.format('%x', ustring.codepoint(frame.args[1])):upper()
    return 'U+' .. string.format('%x', ustring.codepoint(frame.args[1])):upper()
end
end


-------------------------  codepoint  ------------------------------------------
-------------------------  codepoint  ------------------------------------------
---문자 코드를 반환합니다.
---문자 코드를 반환합니다.
---@param data table | string table : frame, string : char
---@param char string
---@param base string example) 10 : U+1234, r10 : 1234, 16(normal) : U+ABCD
---@param base string example) 10 : U+1234, r10 : 1234, 16(default) : U+ABCD
---@param offset integer
---@param offset integer 0(default)
---@return string
---@return string
function p._code(char, base, offset)
    if char == nil then
        return 'char is nil'
    end
   
    if type(char) ~= 'number' then
        return 'char is not a number'
    end
    if type(offset) ~= 'number' then
        return 'offset is not a number'
    end
    base = base or '16'
    local codepoint = ustring.codepoint(char) + (offset or 0)
    if base == 'r10' then
        return codepoint
    end
    local head = 'U+'
    local baseformat = {
        ['10'] = "%d",
        ['16'] = "%x"
    }
    return head .. ustring.format(baseformat[base], codepoint):upper()
end
function p.code(data, base, offset)
function p.code(data, base, offset)
local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
    local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
local char
 
if type(data) == 'table' then
    local char = getArgs(data)[1] or nil
char = getArgs(data)[1] or nil
 
else
    return p._code(char, base, offset)
char = data
end
if type(char) == 'number' or type(char) == 'nil' then
return '입력값이 없습니다.'
end
if offset == nil then offset = 0 end
local baseformat, head
p.codepoint = ustring.codepoint(char)
if base == '10' then
baseformat = '%d';
head = 'U+'
elseif base == 'r10' then
return p.codepoint + offset
else
baseformat = '%x';
head = 'U+'
end
return head ..ustring.upper(ustring.format(baseformat, p.codepoint + offset))
end
end
----------------------  next codepoint  ---------------------------------------
----------------------  next codepoint  ---------------------------------------
---
---
54번째 줄: 68번째 줄:
---@return string
---@return string
function p.nextcode(data)
function p.nextcode(data)
local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
    local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
local char
    local char
if type(data) == 'table' then
    if type(data) == 'table' then
char = getArgs(data)[1] or nil
        char = getArgs(data)[1] or nil
else
    else
char = data or nil
        char = data or nil
end
    end
if char then
    if char then
return p.code(char, '16', 1)
        return p._code(char, '16', 1)
else
    else
return '입력값이 없습니다.'
        return '입력값이 없습니다.'
end
    end
end
end
----------------------  prev codepoint  ---------------------------------------
----------------------  prev codepoint  ---------------------------------------
---
---
73번째 줄: 88번째 줄:
---@return string
---@return string
function p.prevcode(data)
function p.prevcode(data)
local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
    local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
local char
    local char
if type(data) == 'table' then
    if type(data) == 'table' then
char = getArgs(data)[1] or nil
        char = getArgs(data)[1] or nil
else
    else
char = data or nil
        char = data or nil
end
    end
if char then
    if char then
return p.code(char, '16', -1)
        return p._code(char, '16', -1)
else
    else
return '입력값이 없습니다.'
        return '입력값이 없습니다.'
end
    end
end
end
----------------------  next char  ---------------------------------------
----------------------  next char  ---------------------------------------
---
---
92번째 줄: 108번째 줄:
---@return string nextchar
---@return string nextchar
function p.nextchar(data)
function p.nextchar(data)
local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
    local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
local char
    local char
if type(data) == 'table' then
    if type(data) == 'table' then
char = getArgs(data)[1] or nil
        char = getArgs(data)[1] or nil
else
    else
char = data or nil
        char = data or nil
end
    end
if char then
    if char then
return ustring.char(p.code(char, 'r10', 1))
        return ustring.char(p._code(char, 'r10', 1))
else
    else
return '입력값이 없습니다.'
        return '입력값이 없습니다.'
end
    end
end
end
----------------------  prev char  ---------------------------------------
----------------------  prev char  ---------------------------------------
---
---
111번째 줄: 128번째 줄:
---@return string prevchar
---@return string prevchar
function p.prevchar(data)
function p.prevchar(data)
local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
    local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
local char
    local char
if type(data) == 'table' then
    if type(data) == 'table' then
char = getArgs(data)[1] or nil
        char = getArgs(data)[1] or nil
else
    else
char = data or nil
        char = data or nil
end
    end
if char then
    if char then
return ustring.char(p.code(char, 'r10', -1))
        return ustring.char(p._code(char, 'r10', -1))
else
    else
return '입력값이 없습니다.'
        return '입력값이 없습니다.'
end
    end
end
end
----------------------  {{유니코드문자}}  --------------------------
----------------------  {{유니코드문자}}  --------------------------
---@param frame table
---@param frame table
---@return string
---@return string
function p.unicodechar(frame)
function p.uni_char(frame)
local unicodeBlock = require('Module:UnicodeBlock').unicodeBlock
    local unicodeBlock = require('Module:UnicodeBlock').unicodeBlock
local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
    local _buildlink = require('Module:linkwithtemplate').makelink
---@type table
    local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
local args = getArgs(frame)
 
local class
    ---@type table
if args['class'] == 'x' then
    local args = getArgs(frame)
class = ''
 
else
    local class = (args['class'] == 'x') and '' or (args['class'] or 'infobox')
class = args['class'] or 'infobox'
 
end
    local char_current = args[1] or args['기호'] or args['문자'] or nil
local charname = args['이름'] or mw.title.getCurrentTitle().prefixedText
    local char_name = args['이름'] or mw.title.getCurrentTitle().prefixedText
local curr = args[1] or args['기호'] or args['문자'] or nil
    local eng_name = args['영어이름'] or unicodeBlock(char_current)
local eng = args['영어이름'] or unicodeBlock(curr)
    local locale = args['lang'] or 'ko'
local lang = args['lang'] or 'ko'
    local prefix = args['경로'] or ''
local prefix = args['경로'] or ''
 
local arrow = {
    local prev_arrow_icon = '<i class="fas fa-chevron-left uni_char-arrow"></i></span>'
        prev = '<i class="fas fa-chevron-left unicodechar-arrow"></i></span>',
    local prev_char = args['이전'] or args['전문자'];
        next = '<i class="fas fa-chevron-right unicodechar-arrow"></i></span>'
    local prev_linkname = args['전문자이름'] or args['이전이름'] or prev_char
     }
 
    local next_arrow_icon = '<i class="fas fa-chevron-right uni_char-arrow"></i></span>'
     local buildlink = require('Module:linkwithtemplate').makelink
     local next_char = args['이후'] or args['후문자'];
local function link(article, linkname, arrow, preload, editintro)
    local next_linkname = args['후문자이름'] or args['이후이름'] or next_char
 
     local template = args['템플릿']
    local editintro = args['editintro']
 
    local prev_link, next_link
 
    local htmlroot = mw.html.create('table')
        :addClass(class)
        :addClass('uni_char')
        :cssText('margin: 0 auto; float: right; text-align: center; clear:right')
 
    local header
    if char_name == '없음' then
        header = ustring.format('<tr><th colspan="3"><small>%s</small></th></tr>', eng_name)
    else
        header = ustring.format('<tr><th colspan="3"><div>%s</div><small>%s</small></th></tr>', char_name, eng_name)
    end
 
    local function buildlink(article, linkname, arrow, preload, editintro)
         if preload then
         if preload then
             return buildlink(article, string.format('<div>%s<br>%s</div>', linkname, arrow), preload, editintro)
             return _buildlink(article, string.format('<div>%s<br>%s</div>', linkname, arrow), preload, editintro)
         else
         else
             return ustring.format('[[%s|<div>%s<br>%s</div>]]', article, linkname, arrow or '') .. "<div style='display:none;'>" .. (preload or '') .. "</div>"
             return ustring.format('[[%s|<div>%s<br>%s</div>]]', article, linkname, arrow or '')
         end
         end
     end
     end


local htmlroot = mw.html.create('table')
    if char_current == nil then
:addClass(class)
        return '<span class="warning">기호 인수가 없습니다.</span>'
:addClass('unicodechar')
:cssText('margin: 0 auto ;max-width:  ;width: ;float: right; text-align: center; clear:right')
local tr, td
if args['이름'] == '없음' then
tr = ustring.format('<tr><th colspan="3"><small>%s</small></th></tr>',eng)
else
tr = ustring.format('<tr><th colspan="3"><div>%s</div><small>%s</small></th></tr>',charname, eng)
end
local prevlink, nextlink
if curr == nil then
return '<span class="warning">기호 인수가 없습니다.</span>'
     else
     else
         if curr:find("[Uu]") then
         if char_current:find("[Uu]") then
             curr = p.tochar(curr)
             char_current = p.tochar(char_current)
         end
         end
local prevchar = args['이전'] or args['전문자'];
        local prevlinktext = args['전문자이름'] or args['이전이름'] or prevchar
local nextchar = args['이후'] or args['후문자'];
        local nextlinktext = args['후문자이름'] or args['이후이름'] or nextchar
         --------------------- 이전 문자
         --------------------- 이전 문자
if prevchar then
        if prev_char then
prevlink = link(prevchar, prevlinktext, arrow.prev, args['템플릿'], args['editintro'])
            prev_link = buildlink(prev_char, prev_linkname, prev_arrow_icon, template, editintro)
        --- 이전 문자 없으면 자동 계산
            --- 이전 문자 없으면 자동 계산
else
        else
local char = ustring.char(p.code(curr, 'r10', -1))
            local char = ustring.char(p._code(char_current, 'r10', -1))
local pagename = prefix or ''
            local article = prefix .. (ustring.codepoint(char) > 65535 and p._code(char_current, '16', -1) or char)
            local linktext = prevlinktext or char


if ustring.codepoint(char) > 65535 then -- 문서 이름 결정
            prev_link = buildlink(article, prev_linkname or char, prev_arrow_icon, template, editintro)
pagename = pagename .. p.code(curr, '16', -1); -- 문자 코드로
        end
else
pagename = pagename .. char; -- 문자로
end
prevlink = link(pagename, linktext, arrow.prev, args['템플릿'], args['editintro'])
end
         ------------------- 다음 문자
         ------------------- 다음 문자
if nextchar then
        if next_char then
nextlink = link(nextchar, nextlinktext, arrow.next, args['템플릿'], args['editintro'])
            next_link = buildlink(next_char, next_linkname, next_arrow_icon, template, editintro)
        --- 이전 문자 없으면 자동 계산
            --- 이전 문자 없으면 자동 계산
else
        else
local char = ustring.char(p.code(curr, 'r10', 1))
            local char = ustring.char(p._code(char_current, 'r10', 1))
local pagename = prefix or ''
            local article = prefix .. (ustring.codepoint(char) > 65535 and p._code(char_current, '16', 1) or char)
            local linktext = nextlinktext or char
 
           
            next_link = buildlink(article, next_linkname or char, next_arrow_icon, template, editintro)
if ustring.codepoint(char) > 65535 then -- 문서 이름 결정
        end
pagename = pagename .. p.code(curr, '16', 1); -- 문자 코드로
    end
else
 
pagename = pagename .. char; -- 문자로
    local t = {}
end
 
nextlink = link(pagename, linktext, arrow.next, args['템플릿'], args['editintro'])
    local format =
end
    [[<td class='uni_char-prev' style="width: 7em;font-size:1.2em;" lang="%s">%s</td>
end
<td class='uni_char-char' style="width: 6em"><div style="font-size: 1.8em;line-height: 1.4em;"><b lang="%s">%s</b></div>
local format =  
[[<td class='unicodechar-prev' style="width: 7em;font-size:1.2em;" lang="%s">%s</td>
<td class='unicodechar-char' style="width: 6em"><div style="font-size: 1.8em;line-height: 1.4em;"><b lang="%s">%s</b></div>
<div style="font-size:80%%; color: gray; ">%s</div></td>
<div style="font-size:80%%; color: gray; ">%s</div></td>
<td class='unicodechar-next' style="width: 7em;font-size:1.2em;" lang="%s">%s</td>]]
<td class='uni_char-next' style="width: 7em;font-size:1.2em;" lang="%s">%s</td>]]


if args['순서반전'] then
    if args['순서반전'] then
tr = ustring.format(format .. "%s", lang, prevlink, lang, curr, p.code(curr), lang, nextlink, tr)
        header = ustring.format(format .. "%s", locale, prev_link, locale, char_current, p._code(char_current), locale,
else
            next_link, header)
tr = ustring.format("%s" .. format, tr, lang, prevlink, lang, curr, p.code(curr), lang, nextlink)
    else
end
        header = ustring.format("%s" .. format, header, locale, prev_link, locale, char_current, p._code(char_current),
return tostring(htmlroot:node(tr))
            locale, next_link)
    end
    return tostring(htmlroot:node(header))
end
end


return p
return p

2025년 1월 30일 (목) 19:40 판

{{#css: .template-documentation {

   clear: both;
   margin: 1em 0 0 0;
   padding: 1em

} /* 아래 상자 */ .mbox-text {

   clear: both;
   background-color: #e8ffe8;

}

.template-documentation-template-data .mw-templatedata-doc-desc {

   display: none;

}

}}

설명문서 [보기] [편집] [역사] [새로 고침]

모듈:Unicode을 이용합니다. Lua 오류: bad argument #1 to 'char' (number expected, got string). {{유니코드문자|[}}

가장 간단한 코드입니다. 유니코드는 자동으로 입력되므로 입력하실 필요가 없습니다.

Lua 오류: bad argument #1 to 'char' (number expected, got string).

{{유니코드문자|이름=왼쪽 대괄호|[}}

아래는 가능한 모든 변수들을 나열한 것입니다.

왼쪽 대괄호
Left Square Bracket
Z
[
char is not a number
역슬래시




{{유니코드문자
|이름=왼쪽 대괄호
|이전= Z
|문자=[
|이후= \
|이후이름= 역슬래시
|영어이름= Left Square Bracket}}
위 설명은 모듈:Unicode/설명문서의 내용을 가져와 보여주고 있습니다.
연습장이나 사용자 문서에서 틀의 사용이나 수정을 연습할 수 있습니다.
분류는 /설명문서에 넣어주세요. 이 틀의 하위문서.

local mw = mw
local ustring = mw.ustring
local p = {}

------------------------- code to char ------------------------------------------
---@param code string string: U+ABCD
function p.tochar(code)
    return ustring.char(tonumber(code:gsub(" ", ""):gsub("[Uu][+]", "0x"), 16))
end

------------------------- codepoint (frame) ------------------------------------------
---return 'U+ABCD'
---@param frame table
---@return string
function p.tounicode(frame)
    return 'U+' .. string.format('%x', ustring.codepoint(frame.args[1])):upper()
end

-------------------------  codepoint  ------------------------------------------
---문자 코드를 반환합니다.
---@param char string
---@param base string example) 10 : U+1234, r10 : 1234, 16(default) : U+ABCD
---@param offset integer 0(default)
---@return string
function p._code(char, base, offset)

    if char == nil then
        return 'char is nil'
    end
    
    if type(char) ~= 'number' then
        return 'char is not a number'
    end

    if type(offset) ~= 'number' then
        return 'offset is not a number'
    end

    base = base or '16'

    local codepoint = ustring.codepoint(char) + (offset or 0)

    if base == 'r10' then
        return codepoint
    end

    local head = 'U+'
    local baseformat = {
        ['10'] = "%d",
        ['16'] = "%x"
    }

    return head .. ustring.format(baseformat[base], codepoint):upper()
end

function p.code(data, base, offset)
    local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리

    local char = getArgs(data)[1] or nil

    return p._code(char, base, offset)
end

----------------------  next codepoint  ---------------------------------------
---
---입력된 문자의 이후 문자 코드 반환
---@param data table | string table : frame, string : char
---@return string
function p.nextcode(data)
    local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
    local char
    if type(data) == 'table' then
        char = getArgs(data)[1] or nil
    else
        char = data or nil
    end
    if char then
        return p._code(char, '16', 1)
    else
        return '입력값이 없습니다.'
    end
end

----------------------  prev codepoint  ---------------------------------------
---
---입력된 문자의 이전 문자 코드 반환
---@param data table | string table : frame, string : char
---@return string
function p.prevcode(data)
    local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
    local char
    if type(data) == 'table' then
        char = getArgs(data)[1] or nil
    else
        char = data or nil
    end
    if char then
        return p._code(char, '16', -1)
    else
        return '입력값이 없습니다.'
    end
end

----------------------  next char  ---------------------------------------
---
---입력된 문자의 이후 문자 반환
---@param data table | string table : frame, string : char
---@return string nextchar
function p.nextchar(data)
    local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
    local char
    if type(data) == 'table' then
        char = getArgs(data)[1] or nil
    else
        char = data or nil
    end
    if char then
        return ustring.char(p._code(char, 'r10', 1))
    else
        return '입력값이 없습니다.'
    end
end

----------------------  prev char  ---------------------------------------
---
---입력된 문자의 이전 문자 반환
---@param data table | string table : frame, string : char
---@return string prevchar
function p.prevchar(data)
    local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리
    local char
    if type(data) == 'table' then
        char = getArgs(data)[1] or nil
    else
        char = data or nil
    end
    if char then
        return ustring.char(p._code(char, 'r10', -1))
    else
        return '입력값이 없습니다.'
    end
end

----------------------  {{유니코드문자}}  --------------------------
---@param frame table
---@return string
function p.uni_char(frame)
    local unicodeBlock = require('Module:UnicodeBlock').unicodeBlock
    local _buildlink = require('Module:linkwithtemplate').makelink
    local getArgs = require('Module:Arguments').getArgs --- frame 인수 처리

    ---@type table
    local args = getArgs(frame)

    local class = (args['class'] == 'x') and '' or (args['class'] or 'infobox')

    local char_current = args[1] or args['기호'] or args['문자'] or nil
    local char_name = args['이름'] or mw.title.getCurrentTitle().prefixedText
    local eng_name = args['영어이름'] or unicodeBlock(char_current)
    local locale = args['lang'] or 'ko'
    local prefix = args['경로'] or ''

    local prev_arrow_icon = '<i class="fas fa-chevron-left uni_char-arrow"></i></span>'
    local prev_char = args['이전'] or args['전문자'];
    local prev_linkname = args['전문자이름'] or args['이전이름'] or prev_char

    local next_arrow_icon = '<i class="fas fa-chevron-right uni_char-arrow"></i></span>'
    local next_char = args['이후'] or args['후문자'];
    local next_linkname = args['후문자이름'] or args['이후이름'] or next_char

    local template = args['템플릿']
    local editintro = args['editintro']

    local prev_link, next_link

    local htmlroot = mw.html.create('table')
        :addClass(class)
        :addClass('uni_char')
        :cssText('margin: 0 auto; float: right; text-align: center; clear:right')

    local header
    if char_name == '없음' then
        header = ustring.format('<tr><th colspan="3"><small>%s</small></th></tr>', eng_name)
    else
        header = ustring.format('<tr><th colspan="3"><div>%s</div><small>%s</small></th></tr>', char_name, eng_name)
    end

    local function buildlink(article, linkname, arrow, preload, editintro)
        if preload then
            return _buildlink(article, string.format('<div>%s<br>%s</div>', linkname, arrow), preload, editintro)
        else
            return ustring.format('[[%s|<div>%s<br>%s</div>]]', article, linkname, arrow or '')
        end
    end

    if char_current == nil then
        return '<span class="warning">기호 인수가 없습니다.</span>'
    else
        if char_current:find("[Uu]") then
            char_current = p.tochar(char_current)
        end
        --------------------- 이전 문자
        if prev_char then
            prev_link = buildlink(prev_char, prev_linkname, prev_arrow_icon, template, editintro)
            --- 이전 문자 없으면 자동 계산
        else
            local char = ustring.char(p._code(char_current, 'r10', -1))
            local article = prefix .. (ustring.codepoint(char) > 65535 and p._code(char_current, '16', -1) or char)

            prev_link = buildlink(article, prev_linkname or char, prev_arrow_icon, template, editintro)
        end
        ------------------- 다음 문자
        if next_char then
            next_link = buildlink(next_char, next_linkname, next_arrow_icon, template, editintro)
            --- 이전 문자 없으면 자동 계산
        else
            local char = ustring.char(p._code(char_current, 'r10', 1))
            local article = prefix .. (ustring.codepoint(char) > 65535 and p._code(char_current, '16', 1) or char)

            next_link = buildlink(article, next_linkname or char, next_arrow_icon, template, editintro)
        end
    end

    local t = {}

    local format =
    [[<td class='uni_char-prev' style="width: 7em;font-size:1.2em;" lang="%s">%s</td>
<td class='uni_char-char' style="width: 6em"><div style="font-size: 1.8em;line-height: 1.4em;"><b lang="%s">%s</b></div>
<div style="font-size:80%%; color: gray; ">%s</div></td>
<td class='uni_char-next' style="width: 7em;font-size:1.2em;" lang="%s">%s</td>]]

    if args['순서반전'] then
        header = ustring.format(format .. "%s", locale, prev_link, locale, char_current, p._code(char_current), locale,
            next_link, header)
    else
        header = ustring.format("%s" .. format, header, locale, prev_link, locale, char_current, p._code(char_current),
            locale, next_link)
    end
    return tostring(htmlroot:node(header))
end

return p