Character problems in JS (binary/decimal/16 and ASCII conversion) _javascript tips

Source: Internet
Author: User
var a= ' 11160 ';
Alert (parseint (a,2)); Converts 111 to 2, ignoring 60 (not conforming to binary), and converting from left to right only binary numbers are converted
Alert (parseint (a,16)); Convert all of them
In this way, it can actually be converted into any system
var a= ' 1110 ';
Alert (parseint (a,10). toString (16)); Converting a to 10 and then converting to 16 can also be a different system
Here's the ASCII code:
function Test () {
var a= ' AB ';
var c=a.charcodeat (1);//Return 98 is the ASCII position of B starting from 0

var char=string.fromcharcode (98); Returns a lowercase b
}
Small example
Characters in the function test () {//output ASCII extension set
var c= "";
for (Var i=1;i<65536;i++) {
if ((i%10) ==0) {
c+=i+ ': \ t ' +string.fromcharcode (i) + ' \ t ' + ' \ n ';} else{
c+=i+ ': \ t ' +string.fromcharcode (i) + ' \ t ';}
}
document.getElementById ("abc"). Innertext=c;
}
<div id= ' abc ' ></div>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.