Why does this substring not work in Chinese? I get the correct results for other languages, but in Chinese I got an empty string.
countryID = "奥地利(销售超过3万5千欧元)"; countryID.substring(0, countryID.indexOf('(') - 1); countryID = "Austria (Sales > €35,000)"; countryID.substring(0, countryID.indexOf('(') - 1);
(and Chinese (are different Unicode characters. You must use .indexOf('(')for Chinese characters.
(
(
.indexOf('(')
Example:
<div id='d1'></div> <script> var countryID = "奥地利(销售超过3万5千欧元)"; document.getElementById('d1').innerHTML=countryID.indexOf('('); </script>
Because '(' is not in countryID, '(' and '(' are different characters, the first is Chinese style.
countryID
So you can use:
countryID.substring(0, countryID.indexOf('(') - 1);
Source: https://habr.com/ru/post/1689579/More articles:Why do MIX dependencies have a “~>” before the semantic version of the dependency? - elixirFill out the web form from the application and submit - androidWhen is a structure (user data type) created? - cGCC - macro containing flag compilation - c ++Using map and lambda to count frequencies in a dictionary - pythonHow can I arrange the flex child before the parent? - htmlКак работает копия FFMPEG? - ffmpegDuplicate bulb shape data on submit - pythonHow to switch content display using multiple Bootstrap 4 display classes - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1689584/add-page-headers-to-roxygen2-docs&usg=ALkJrhiPT-rby7ZgE_tbVtoFZg5PBFRJ4wAll Articles