techniboogie-dart / recase

BSD 2-Clause "Simplified" License
103 stars 15 forks source link

.titleCase changes ' i ' to ' I ' instead of ' İ ' #7

Open yasinarik opened 4 years ago

yasinarik commented 4 years ago

.titleCase changes i to I instead of İ Can you provide a quick fix?

I have tried with ş ç ğ ü ö They become Ş Ç Ğ Ü Ö so no problem.

THANKS for this great package ☺️

nitehogg commented 4 years ago

Hm. This may be a dart bug... here's some tests in dartpad..

void main() {
  print('İ => ${'İ'.toLowerCase()} => ${'İ'.toLowerCase().toUpperCase()}');
  print('${'İ'.codeUnits} => ${'İ'.toLowerCase().codeUnits} => ${'İ'.toLowerCase().toUpperCase().codeUnits}');
}
İ => i̇ => İ
[304] => [105, 775] => [73, 775]

Normally, I wouldn't blame the base language...but I'm not sure what else to think.

Also strange, if you look at the output here in the github, the re-uppercase looks fine... but in dartpad, the dot is offset.

nitehogg commented 4 years ago

I may play around with it some more.. can you send me an example string that you're seeing the issue with?

nitehogg commented 4 years ago

It looks like it's breaking up the character into two code...but then just uppercasing the first half of the code (73 = 'I')

yasinarik commented 4 years ago

can you send me an example string that you're seeing the issue with?

Sure! Here you are :) Also thanks for the very quick reply!

"insan".titleCase--> "Insan" . It must be "İnsan"

"Siparişler".toUpperCase() --> "SIPARIŞLAR" . However it must be "SİPARİŞLER"

@nitehogg EDIT: Well, actually this is a very particular case that happens in Turkish (and maybe some other langs.) I mean if the text is in English, ReCase works as expected since there is not the upper case "i" in English. However, the Turkish Language has both "ı" , "i" , "I" , "İ".

The logic here should be that ReCase may be added with exceptional situations of different languages. For example ReCase(text, langCode).titleCase

mateusfccp commented 4 years ago

Maybe this can be leveraged with the Characters package?

nitehogg commented 4 years ago

@mateusfccp I was thinking the same thing. I'm going to give it a try sometime this week.