Editing
Module:Convert character width
From Thetacola Wiki
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- 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
Summary:
Please note that all contributions to Thetacola Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Project:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Module:Arguments
(
edit
)
Module:Convert character width
(
edit
)
Module:Convert character width/data
(
edit
)
Module:Convert character width/doc
(
edit
)
Module:Effective protection level
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Yesno
(
edit
)
Navigation menu
Page actions
Module
Discussion
Read
Edit source
History
Page actions
Module
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Tools
What links here
Related changes
Special pages
Page information