Questions tagged [fromcharcode]

String.fromCharCode() is a static method in JavaScript that returns a string based on the unicode number passed in. To use this tag, the question must be using JavaScript and one of the primary issues is regarding String.fromCharCode().

String.fromCharCode() accepts UTF-16 code units and converts them to the representative string.

String.fromCharCode(65) // returns A

The method can accept up to 65535 code units to return multiple characters.

String.fromCharCode(65, 66, 67) // returns ABC

If the method is called with no parameters, it outputs a zero-length string.

You can also pass parameters in hexadecimal notation.

String.fromCharCode(0x41) // returns A

If a number larger than 65535 (0xFFFF) is passed as a parameter it will be truncated. For example:

String.fromCharCode(65535) 

65535 (1111111111111111) is the maximum and will output . However,

String.fromCharCode(65536)

65536 (10000000000000000) is over the maximum 16 bits and so will get truncated to 0000000000000000 which will then output a zero-length string.

References

69 questions
0
votes
0 answers

Some of the html entity code not visible in chrome browser ex: ࠅ

Some of the entity code are unhandled in chrome browser, Please help and suggest alternate way to dispaly the symbols.. Entity code sample website link: https://www.compart.com/en/unicode/block/U+2000 Ex: HTML Entity: (&)#x2053; = ~ Thanks
0
votes
2 answers

Array.join inserts extra characters when joining strings created with String.fromCharCode

I have an array of bytes that I would to to encode to a string to pass to btoa in the browser. These bytes use the full 0-255 range. I encountered what at first seemed to be a bug with btoa, but it turns out to be a bug (or at least quite…
undefined
  • 6,208
  • 3
  • 49
  • 59
0
votes
1 answer

How to handle negative or unsigned char when porting from C/C++ to JavaScript?

I'm trying to port an old C++ lexer (source) to JavaScript and am struggling a bit with my non-comprehension of C/C++. I have a parameter c which as I currently see it could either be an index of the position on a chunk of an input file I'm parsing…
frequent
  • 27,643
  • 59
  • 181
  • 333
0
votes
1 answer

How do you use a key to generate new code when using charCodeAt()?

I have been working on my science fair project that is due in 3 days and I need help. I using charCodeAt(), however I don't know how to write the code that will use the key and charCodeAt() to create a new code. Please help.
0
votes
1 answer

How to convert function String.fromCharCode in javascript to function in php

I have a new question. I have short code js: SenAffet += String.fromCharCode(parseInt(YaRabbim.substr(n, 2), 16)); How to convert it to PHP?
Li Seen
  • 11
  • 1
0
votes
0 answers

Rot13 Cipher in Javascript: How come one of my functions ignores all non-alphabetical characters while the other doesn't?

Javascript: function decRot13(str) { var decode = ''; for(var i = 0; i < str.length; i++){ if(str.charCodeAt(i) + 13 > 90) //make calculations to reset from 65 to find new charCode value decode…
mincedMinx
  • 159
  • 1
  • 3
  • 12
0
votes
3 answers

Problems with Shift Cipher (ROT-13) function and String.fromCharCode in JS

Trying to get a JS function to work that shifts the individual characters in a string by a set amount (and then returns the new "shifted" string). I'm using ROT-13 (so A-M are shifted down 13 characters and N-Z are shifted up 13 characters). The…
GoMagikarp
  • 85
  • 1
  • 7
0
votes
1 answer

String.fromCharCode issue for special characters in javascript

Below code accepts a character and prints character using keycode(String.fromCharCode). Issue arises when you enter special character like . or ?. function logChar(e){ var keyCode = e.which || e.keyCode; var char =…
Rajesh
  • 24,354
  • 5
  • 48
  • 79
0
votes
1 answer

iMacros +JavaScript (using Char function)

I'm trying to program a short script that emulates human behavior, which includes pressing the keyboard END key. Not sure how I can make it work. Using iimPlayCode("String.fromCharCode(35)"); doesn't work as this is a STRING function and I need it…
0
votes
0 answers

way for converting capital ascii codes to lower case ascii codes

I need to efficiently convert the code of a capital char to its correspondent code in lower case. ie: Convert the ascii code 97 to 65. Corresponding to "A" and "a" An wrong answer may be just to add or sustract 32 to that integer. This would only…
plmk
  • 2,194
  • 1
  • 15
  • 21
0
votes
2 answers

Purpose of -1 in String.fromCharCode(k)

I have the following snippet of code : return (AllowableCharacters.indexOf(String.fromCharCode(k)) != -1); Now, I don't quite get the usage of -1 in this script. The way the script reads is as follows: first String.fromCharCode(k) != -1 is…
Alexander Solonik
  • 9,838
  • 18
  • 76
  • 174
0
votes
0 answers

String.fromCharCode((x >> y) | z) operation?

I've been doing some work with url's and uri's and I have a question regarding a function I was using to encode/decode. I've looked up online, and found a function to properly encode my code, using mostly String.fromCharCode() method. But the…
Thiago Loddi
  • 2,212
  • 4
  • 21
  • 35
0
votes
1 answer

Convert array with 8bit value to string with char (no charcode)

I found an elegant code to converts ArrayBuffer into charCode. But I need char, instead of charCode. function ab2s (buf) { var view = new Uint8Array (buf); return Array.prototype.join.call (view, ","); } I tried return Array.prototype.join.call…
bedna
  • 1,330
  • 11
  • 20
0
votes
2 answers

Java: Read file from specific point till end of line

How do I read a file from a specified position to the end of that line. Example: File Contents: 01234567 f1=value f2=value f3=value 01234567 = character position. I want it to start reading the line from the "v" in value and I want it to read till…
0
votes
2 answers

Adding Multiple Arguments into an built in function, from a function

I'm trying to add String.fromCharCode(). And adding it into a function that renames it like so: function from() { var ar = arguments.length; var argumentss = ''; for (var i = 0; i < ar; i++) { var a = argumentss + '\'' +…
Shawn31313
  • 5,978
  • 4
  • 38
  • 80