28
Mar
09

[Javascript] Char Code to Unicode Fullwidth Latin

The below code is used for converting normal strings of characters to strings of Fullwidth Latin Unicode characters.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" >
<head >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" / >
<title > Untitled Document</title >
<script language="javascript" type="text/javascript" >
function code() {
	var ine = document.getElementById('in');
	var oute = document.getElementById('out');
	oute.value = ""
	for(i=0; i<ine.value.length; i++) {
		if(ine.value.charCodeAt(i)  > = 33 && ine.value.charCodeAt(i) <= 270) {
			oute.value += String.fromCharCode(ine.value.charCodeAt(i) + 65248);
		} else if(ine.value.charCodeAt(i) == 32) {
			oute.value += String.fromCharCode(12288);
		}
	}
}
</script >
</head > 

<body >
<form id="form1" name="form1" method="post" action="" >
	<textarea name="textarea" id="in" cols="70" rows="7" onkeyup="code()" > </textarea>   <br /> <br />
	<textarea name="textarea" id="out" cols="70" rows="7" > </textarea>
</form >
</body >
</html >

Usage:
The above code creates 2 text areas. Type into the top and the bottom box will output the Unicode equivalent, e.g.
https://sim0n.wordpress.com/
http://sim0n.wordpress.com/

Advertisements

0 Responses to “[Javascript] Char Code to Unicode Fullwidth Latin”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: