Module:Convert character width
मॉड्यूल बिबरनलेख[देखीं] [संपादन करीं] [इतिहास देखीं] [रिफ्रेश करीं]
This module is rated as alpha. It is ready for third party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome. |
This module converts a limited set of characters between halfwidth and fullwidth forms.
Usage
संपादन करीं- From half-width to full-width
{{#invoke:convert character width|full|text to convert}}
- From full-width to half-width
{{#invoke:convert character width|half|text to convert}}
उदाहरण
संपादन करीं{{#invoke:convert character width|full|some text 0123456789}}
→ some text 0123456789{{#invoke:convert character width|half|some text 0123456789}}
→ some text 0123456789
Support
संपादन करींCare should be taken when using this module with Hangul and katakana; as of September 2013 there is only limited support for katakana and no support for Hangul. Some of the more obscure punctuation characters are also not yet supported.
Data
संपादन करींThe character data used by the module is located at Module:Convert character width/data. Fixes and updates to the data set are welcomed enthusiastically.
परिचय खातिर ऊपर दिहल गइल बिबरनलेख के Module:Convert character width/doc से ट्रांसक्लूड क के इहाँ देखावल जा रहल बाटे। (संपादन करीं | इतिहास देखीं) संपादक लोग एह मॉड्यूल के अभ्यासपन्ना (सैंडबाक्स) (बनाईं | मिरर करीं) आ टेस्टकेस (बनाईं) पन्ना पर अभ्यास भा प्रयोग (टेस्टिंग) क सकत बाटे। एह मॉड्यूल के उपपन्ना (सबपेज) देखीं। |
-- This module converts support characters from half-width to full-width, and vice versa.
-- See [[Halfwidth and fullwidth forms]] for an explanation of half- and full-width characters.
-- @todo FIXME: Needs more characters adding, needs support for diacritic marks.
local data = mw.loadData( 'Module:Convert character width/data' )
local p = {}
-- Converts one half-width character to one full-width character.
local function getFull( s )
return data[ s ] or s
end
-- Converts one full-width character to one half-width character.
local function getHalf( s )
for half, full in pairs( data ) do
if s == full then
return half
end
end
return s
end
-- Converts multiple half-width characters to full-width characters.
function p.full( frame )
local s = type( frame ) == 'table' and frame.args and frame.args[ 1 ] or frame
s = type( s ) == 'number' and tostring( s ) or s
if type( s ) ~= 'string' then return end
return ( mw.ustring.gsub( s, '.', getFull ) )
end
-- Converts multiple full-width characters to half-width characters.
function p.half( frame )
local s = type( frame ) == 'table' and frame.args and frame.args[ 1 ] or frame
s = type( s ) == 'number' and tostring( s ) or s
if type( s ) ~= 'string' then return end
return ( mw.ustring.gsub( s, '.', getHalf ) )
end
return p