中文编程
首发于中文编程

向LeetCode报告编译信息中Unicode显示问题

鉴于前文在LeetCode中的解答中使用中文命名发现了这个问题, 向LeetCode的General Support电邮发了个请求/报告. 不到两个小时后收到客服的回信:

Thanks for your feedback. I have filed an issue to the team and we will take a look at it soon!

将继续跟进.


附上报告原文:

Message: request for better support for unicode identifier in program
First of all, thanks a lot for supporting unicode identifier in the code, as I can pass this in two-sum problem (leetcode.com/problems/t) without issue:
class Solution {
  public int[] twoSum(int[] 数列, int 目标和) {
      int[] 索引对 = new int[2];
      for (int i = 0; i < 数列.length; i++) {
          for (int j = i + 1; j < 数列.length; j++) {
              if (数列[i] + 数列[j] == 目标和) {
                  索引对[0] = i;
                  索引对[1] = j;
                  return 索引对;
              }
          }
      }
      return 索引对;
  }
}
Just one thing I notice, the compile error doesn't display the unicode identifier correctly. For example, a small change in the code:
class Solution {
   public int[] twoSum(int[] 数列, int 目标和) {
       int[] 索引 = new int[2];   <------ name has typo, 索引 should be 索引对
       for (int i = 0; i < 数列.length; i++) {
           for (int j = i + 1; j < 数列.length; j++) {
               if (数列[i] + 数列[j] == 目标和) {
                   索引对[0] = i;
                   索引对[1] = j;
                   return 索引对;
               }
           }
       }
       return 索引对;
   }
} 
will result in compile error as below.
Line 7: error: cannot find symbol: variable ???

I'd appreciate a lot if this could be improved. Thanks!

编辑于 2017-11-30

文章被以下专栏收录

    在所有编程语言和领域中尝试编写中文代码,开发相关工具,总结经验,一致代码风格。包括中文命名,汉化现有语言,创造中文语法的编程语言等等。作为最熟悉的母语,用来编写代码会让代码更容易被自己和母语相同的其他开发者理解。基于英文的编程语言和框架中,使用中文命名有时有技术问题。希望这里为后人趟雷,填坑。多数现有API是英文的,这里也会对其中一些常用的进行汉化。当然,这里也会对基于中文的编程语言进行探讨。包括汉化基于英文的编程语言,以及创造新的编程语言。