Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage  





2 Examples  





3 Support  





4 Data  














Module:Convert character width






العربية
Авар
تۆرکجه
Basa Bali

Буряад
Cebuano
الدارجة
فارسی

ि
Bahasa Indonesia

Македонски

 / Mìng-dĕ̤ng-nḡ
ି
Oʻzbekcha / ўзбекча

Qaraqalpaqsha
Русиньскый

Scots

Simple English
کوردی
ி

Українська
اردو
Tiếng Vit

 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 


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}}

Examples

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.

-- 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

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Convert_character_width&oldid=1177868862"

Category: 
Modules subject to page protection
Hidden category: 
Wikipedia template-protected modules
 



This page was last edited on 30 September 2023, at 03:30 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki