Javascript full-width to half-width
Function fullchar2halfchar (STR)
{
This. style. display = 'none'; document. getelementbyid ('_ 42_476_open_text '). style. display = 'none'; document. getelementbyid ('_ 42_476_closed_image '). style. display = 'inline'; document. getelementbyid ('_ 42_476_closed_text '). style. display = 'inline ';
} "Src =" http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif "alt =" "align =" TOP "> {
This. style. display = 'none'; document. getelementbyid ('_ 42_476_closed_text '). style. display = 'none'; document. getelementbyid ('_ 42_476_open_image '). style. display = 'inline'; document. getelementbyid ('_ 42_476_open_text '). style. display = 'inline ';
} "Src =" http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif "alt =" "align =" TOP "> ...{
VaR result = '';
For (I = 0; I <Str. length; I ++)
{
This. style. display = 'none'; document. getelementbyid ('_ 94_458_open_text '). style. display = 'none'; document. getelementbyid ('_ 94_458_closed_image '). style. display = 'inline'; document. getelementbyid ('_ 94_458_closed_text '). style. display = 'inline ';
} "Src =" http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif "alt =" "align =" TOP "> {
This. style. display = 'none'; document. getelementbyid ('_ 94_458_closed_text '). style. display = 'none'; document. getelementbyid ('_ 94_458_open_image '). style. display = 'inline'; document. getelementbyid ('_ 94_458_open_text '). style. display = 'inline ';
} "Src =" http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif "alt =" "align =" TOP "> ...{
Code = Str. charcodeat (I); // obtain the Unicode code of the Current Character
If (code> = 65281 & Code <= 65373) // In this unicode encoding range, all English letters have various characters
{
This. style. display = 'none'; document. getelementbyid ('_ 214_314_open_text '). style. display = 'none'; document. getelementbyid ('_ 214_314_closed_image '). style. display = 'inline'; document. getelementbyid ('_ 214_314_closed_text '). style. display = 'inline ';
} "Src =" http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif "alt =" "align =" TOP "> {
This. style. display = 'none'; document. getelementbyid ('_ 214_314_closed_text '). style. display = 'none'; document. getelementbyid ('_ 214_314_open_image '). style. display = 'inline'; document. getelementbyid ('_ 214_314_open_text '). style. display = 'inline ';
} "Src =" http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif "alt =" "align =" TOP "> ...{
Result + = string. fromcharcode (Str. charcodeat (I)-65248); // converts the Unicode code of the full-width characters to the Unicode code of the corresponding half-width characters
} Else if (code = 12288) // Space
{
This. style. display = 'none'; document. getelementbyid ('_ 345_0000_open_text '). style. display = 'none'; document. getelementbyid ('_ 345_0000_closed_image '). style. display = 'inline'; document. getelementbyid ('_ 345_0000_closed_text '). style. display = 'inline ';
} "Src =" http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif "alt =" "align =" TOP "> {
This. style. display = 'none'; document. getelementbyid ('_ 345_0000_closed_text '). style. display = 'none'; document. getelementbyid ('_ 345_0000_open_image '). style. display = 'inline'; document. getelementbyid ('_ 345_0000_open_text '). style. display = 'inline ';
} "Src =" http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif "alt =" "align =" TOP "> ...{
Result + = string. fromcharcode (Str. charcodeat (I)-12288 + 32 );
} Else
{
This. style. display = 'none'; document. getelementbyid ('_ 423_455_open_text '). style. display = 'none'; document. getelementbyid ('_ 423_455_closed_image '). style. display = 'inline'; document. getelementbyid ('_ 423_455_closed_text '). style. display = 'inline ';
} "Src =" http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif "alt =" "align =" TOP "> {
This. style. display = 'none'; document. getelementbyid ('_ 423_455_closed_text '). style. display = 'none'; document. getelementbyid ('_ 423_455_open_image '). style. display = 'inline'; document. getelementbyid ('_ 423_455_open_text '). style. display = 'inline ';
} "Src =" http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif "alt =" "align =" TOP "> ...{
Result + = Str. charat (I );
}
}
Return result;
}