T
T
toaster khabrovich2016-01-14 12:44:19
JavaScript
toaster khabrovich, 2016-01-14 12:44:19

Why do the characters Yo and Y split in two?

how to enter the characters Y and Y as whole unicode characters?

<span onclick='ввод_символа("й");'>Й</span>        //побуквенный ввод

var слово = редактируемая_строка.textContent;   //введенное слово

 for (var x=0; x< слово.length; x++)       //разбор слова и вывод его побуквенно
                                 {
                                 var буква = document.createElement('span');
                                 буква.textContent = слово[x];
                                 document.appendChild(буква);
                                 };

at the js level there are no problems
, the word received after entering is sent to the php server where the file of the same name is successfully created from it,
but after receiving the name of this file by javascript, the characters e and d are obtained as pairs of characters

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
ozzzi, 2016-01-14
@studententer

In unicode, a character can be represented as one or two characters, depending on the type of normalization: habrahabr.ru/post/45489
You can try using the normalize () method:
'ё'.normalize('NFC').length == 1- true
while
'ё'.normalize('NFD').length == 2- true

A
Alexander Aksentiev, 2016-01-14
@Sanasol

https://jsfiddle.net/hvh4h9j2/
didn't detail anything.
Alternatively, also like this https://jsfiddle.net/0r9t1h6o/1/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question