我应该避免在变量名中使用unicode字符吗? [英] Should I avoid using unicode characters in variable names?

查看:151
本文介绍了我应该避免在变量名中使用unicode字符吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#语言规范说我们可以在说明符中使用Unicode字符(类和变量名等)

The C# language specification says we can use unicode characters in specifiers (class and variable names, etc.)

我在代码中做了很长的路要走.由于我住在巴西,所以其中包含很多带重音符号的字符,并带有诸如rotaçãoângulomáximo等的变量名.

I went a long way doing this in my code. Since I live in Brazil, this includes lots of accented characters, with variable names such as rotação, ângulo, máximo, etc.

每当一个经验更丰富"的开发人员都意识到这一点时,我强烈建议您避免使用它,并将一切变回原本的状态,否则很多小猫会死掉.

Everytime a more "experienced" developers catches this, I am STRONGLY advised to avoid it and change everything back, otherwise a lot of kittens will die.

我走了很长一段路撤消,但是今天我发现在很早以前编写的方法中,仍有一些仍带有重音符号的变量,到目前为止,还没有小猫死(至少不是因为那个).

I went then a quite long way undoing it, but today I found some variables still named with accents, in methods written long ago, and no kitten died so far (at least not because of that).

由于我的语言(葡萄牙语)是重音符号,因此如果我们的代码库包含这些字符,这很有意义,因为C#明确允许它.

Since my language (portuguese) is accented, it wold make a lot of sense if our codebase has those characters, since C# explicitly allows it.

所以问题是:

是否有 sound 技术上的理由不在C#/VisualStudio代码库中使用Unicode字符?

Are there any sound TECHNICAL reason not to use unicode characters in C#/VisualStudio codebases?

推荐答案

不使用Unicode变量名称的一些原因:

A few reasons why not to use Unicode variable names:

  1. 这使人们很难打字
  2. 某些Unicode字符看上去与非母语使用者非常相似(请参见土耳其语I的情况)
  3. 某些编辑器可能无法正确显示它们
  4. https://twitter.com/Stephan007/status/481001490463866880/photo/1
  1. It makes it hard for people to type them
  2. Some Unicode characters look very similar to non-native speaker (see the case of the Turkish I)
  3. Some editors might not display them correctly
  4. https://twitter.com/Stephan007/status/481001490463866880/photo/1

这篇关于我应该避免在变量名中使用unicode字符吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆