Is support for non-english characters common in programming languages? I mean, technically, I would think it is feasable, but I don’t have any experience in anything other than english, so I don’t know how common it is.
I know that there are non-english based programming languages, but can something like C#, C++, C, Java, or Python support non-english classes/methods/variables?
Example in go (url, http://play.golang.org/p/wRYCNVdbjC)
package main
import "fmt"
type 世界 struct {
世界 string
}
func main() {
fmt.Println("Hello, 世界")
世界 := new(世界)
世界.世界 = "hello world"
fmt.Println(世界.世界)
}
3
Support for non-ASCII literals is present in virtually every modern language. That is, you can write something like japanese = "今日は世界"
in Java, Python, Go, C#, Ruby, etc.
Support for non-ASCII identifiers, that is, things like 英語で = "Hello world"
is also widespread. Languages that allow this, among others, are: Java, Python 3, but not 2 and 1, C#, etc.
Take a look at this lengthy list.
Erm… In the past I’d been programming in English but to support Asian language (mostly Chinese) in the UI.
For most of the coding, we use English.
Only for the UI matter, i.e. label in Windows Forms, Row Header in GridView, text within html/aspx, we will use Chinese.
Thus, we won’t code something like this…
type 世界 struct {
世界 string
}
But will have things like
<b>你好, 欢迎你到来。</b>
I think that this question is somewhat wider than “can I write Kanji in my favorite programming language”.
For Java (and probably most other languages) Unicode is supported, and strings should be externalized to property files or similar. This lets you handle some common internationalization issues:
- The messages are required in multiple languages (well that is what internationalization is about)
- The position of parameters may vary between languages. For instance “The beautiful woman” in English may morph into the equivalent of “The woman beautiful” in other languages.
- If your application supports multiple languages, then most developers will not be fluent in all the deployed languages. Again it is best if you support a single developnment language, and employ foreign language nationals to translate into other languages.
Although non-ASCII identifiers are supported in a large number of programming languages as 9000 and AhJian have said, it would be bad practice to use such and there are several reasons to do that.
The first one is that in some moment in feature a foreign coworkers that don’t understand the language can join the the team, or the code may need to be reviewed by foreign experts or consultants. For them will be very hard to understand the code.
The second one, related to the first, is that you may not get help or review in StackExchange network if you don’t replace the identifiers with english ones.
The third reason is that many of the programming terms are not translated in the particular language.
Almost all languages support non-ASCII characters directly or indirectly.
E.g. in Java you can directly give the non-ASCII characters; But in C# you have to use an escape character sequence i.e.u00e1
for á
.
Support for non-ASCII is also dependent on the text editor you are using.
1