Home > Net >  string with dash downcase
string with dash downcase

Time:08-03

I have a very strange behaviour I cant't tell why this is happening.

"CWSDCTAX-1".downcase == "cwsdctax-1".downcase
=> false
(0..9).to_a.map{ |i| "cwsdctax–1".downcase[i] == "CWSDCTAX-1".downcase[i] }
=> [true, true, true, true, true, true, true, true, false, true]

Why does this happen? I can't figure out why there is a difference?

CodePudding user response:

Can you check the Unicode value for both -, it might be the case that even though it looks similar it has a different Unicode.

Refer to this link to check different dashed and hypes https://jkorpela.fi/dashes.html

[29] pry(main)> '-'.bytes
=> [45]
[30] pry(main)> '-'.bytes
=> [45]
[31] pry(main)> '‐'.bytes
=> [226, 128, 144]
[32] pry(main)> '-' == '‐'
=> false
[33] pry(main)> 
  • Related