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
1
vote
2 answers

javascript string character manipulation

My challenge is to create a function that takes in a string and returns a new string with each character advanced 1 space of the alphabet. Ex: "hello" returns "ifmmp." I haven't yet wrapped my code in a function. This will get me the first new…
adam.shaleen
  • 993
  • 3
  • 9
  • 20
1
vote
1 answer

String.fromCharCode only works with one character

I have javascript code: s = String.fromCharCode(s); This works but it only works with one character even though the String.fromCharCode method is supposed to work with multiple characters seperated by commas. Any ideas why this is?
Rey
  • 23
  • 3
0
votes
1 answer

Caesar Cipher - FCC / Javascript - I can't figure out if why the result is not right

I have tried to solve the Caesar Cipher project of FCC with a few inspirations from the web but I can't figure out why my following code isn't working. I think it's a problem between charCodeAt() and the result integration in the array?! I would…
Reggroy
  • 53
  • 5
0
votes
1 answer

How to no allow negative decimal and 0 value to an input type number in React JS

I have a input box which should not allow negative decimal value and 0 trying to do using charcode as shown below
DhanaLaxshmi
  • 424
  • 1
  • 11
  • 24
0
votes
0 answers

How to decode/replace all charCodes with characters in a string using javascript?

I am using wiris editor within TinyMCE editor in one of my projects. For some reason I want to replace all charCodes used in content with just character, I know that I can do it for every character 1 by 1 like: str.replace("&",…
0
votes
1 answer

How to check Unicode ranges requiring more than 4 character length using Javascript?

Following the question How to check Unicode input value in JavaScript?, I noticed that Unicode character ranges having more than 4 character length (for example Grantha Unicode Block cannot be captured using the following code; function…
linguistan
  • 25
  • 6
0
votes
3 answers

For loop is stopping when rest of the block is added

I wrote a simple for loop, to understand charCodeAt() and fromCharCode() better and to solve the odin project the Caesar cipher exercise where you have to write function to encode a string. It stops at the first iteration and I don´t know why. When…
Karl
  • 13
  • 5
0
votes
0 answers

String.fromCharCode show different output on different browsers

I think these output should be the same.according to https://asecuritysite.com/coding/asc2. But it displays output differently on different browser.why? Also it's bad for code like fromCharCode running on multiple browser.Function's output is…
codenoobforreal
  • 101
  • 1
  • 5
0
votes
1 answer

Problem with convert string with array to integer array by .charCodeAt()

My task is to write a function that changes a string to an integer. If the value is greater than zero, I have to save it in a new array, if it is not to be filtered, the same as the digits that are in the array. tab1 = ['d', 'e', 3, 'h', 11, -2,…
0
votes
1 answer

Output result of string conversion from HEX to ASCII is not expected via function fromCharCode

I am new to Javascript, I am trying to write an app with React Native to accept keyboard like input from external RFID device. by using react-native-keyevent we can capture the input from RFID device, the keycode captured by react-native keyevent…
Zeng Vincent
  • 83
  • 1
  • 5
0
votes
2 answers

Javascript: Replace special character code 8222 fails

In Germany, text processors in its wisdom like to put lower quotes at the beginning of a word and upper at the end. So you end up with a text with unicode 8222 codes in there and running .search(String.fromCharCode(8222)) finds the occurrence just…
Frank E
  • 45
  • 1
  • 7
0
votes
1 answer

console says cant read charCodeAt property