sean-parent / tools

A place for scripts and tooling I find useful
32 stars 4 forks source link

Unicode characters are messy #4

Closed Mad-Thanos closed 5 years ago

Mad-Thanos commented 5 years ago

To reproduce this issue, you can try to reformat the following code snippet:

  if (![helper verify:faceInfo] || ![helper insideScreen:faceInfo]) {
    [self updateFaceInfoOnUIThread:faceInfo];
    [self updateTrackingLabelOnUIThread:@"检测不到人脸"];
    return nil;
  }

In my xcode(10.3 on Mojave 10.14.6), the chinese string "检测不到人脸", will turn into "妫ü娴‹涓�ˆ颁汉�„�" after reformatted, namely a garbled string.

Could you please help?

Mad-Thanos commented 5 years ago

There seemed to be a garbled string in the script as well: https://github.com/sean-parent/tools/blob/2e70670e50385f8ef1b6089a68f2688994ce0b57/xcode-clang-format.applescript#L72

sean-parent commented 5 years ago

I believe the script should now handle utf-8 text correctly in source files. The script file itself is in MacRoman encoding (script files have an "odd" relationship to utf-8 - making the changes to support utf-8 encoding in source files added some additional non-unicode characters. Unfortunate, but I'm not aware of a fix.