Asim Koirala
Asim Koirala

Reputation: 41

I want to make a text converter to unicode converter. The code was going pretty well but I am stuck at changing as '\' is shown invalid

else if (arr2[i] == ']') {
  mainarr.push('े')
} else if (arr2[i] == '}') {
  mainarr.push('ै')
} else if (arr2[i] == '\') {
  mainarr.push('्')
}

I want to make a text converter to Unicode converter. The code was going pretty well but I am stuck at changing as '' is shown invalid. Any way I can type '/'?

Upvotes: 1

Views: 83

Answers (1)

RMiller
RMiller

Reputation: 119

Backslash is often interpreted as an "indication of literal next" - meaning that the next character should NOT be interpreted. In the case above, I would guess that the compiler (and your IDE) is thinking that you meant to say that the single quote is literal.

To fix, make it a double backslash (aka, a literal backslash):

} else if (arr2[i] == '\\') { 

Upvotes: 2

Related Questions