I got an email from a Chinese user explaining that he has to switch the input from Chinese to English in order to type parenthesis in an expression. It would be really convenient for Chinese users if it is possible to use the Chinese full-width variants of characters like parentheses.
This Wikipedia page gives a useful overview: https://en.wikipedia.org/wiki/Chinese_punctuation#Marks_similar_to_European_punctuation. The characters that are relevant for mathjs are:
| Chinese full-width character |
Chinese full-width code |
English character |
Character name |
, |
U+FF0C |
, |
Comma |
、 |
U+3001 |
, |
Enumeration comma |
! |
U+FF01 |
! |
Exclamation mark |
? |
U+FF1F |
? |
Question mark |
; |
U+FF1B |
; |
Semicolon |
: |
U+FF1A |
: |
Colon |
( |
U+FF08 |
( |
Left parenthesis |
) |
U+FF09 |
) |
Right parenthesis |
[ |
U+FF3B |
[ |
Left square bracket |
] |
U+FF3D |
] |
Right square bracket |
If there is indeed need for this, we can implement support for it in two ways:
- Simple way: in the parse function, write a regular expression which replaces all full-width Chinese characters with their English variant. Or we could just provide two helper functions to replace Chinese full-width characters with their English variants and vice versa.
- More work: similar to functions like
parse.isDigit, introduce functions like isParenthesisOpen which test for the English and Chinese variant of the character. We can also think though how to make sure that stringifying an expression keeps track on the originally used character. I'm not sure if this is worth the added complexity though.
Any thoughts:
I got an email from a Chinese user explaining that he has to switch the input from Chinese to English in order to type parenthesis in an expression. It would be really convenient for Chinese users if it is possible to use the Chinese full-width variants of characters like parentheses.
This Wikipedia page gives a useful overview: https://en.wikipedia.org/wiki/Chinese_punctuation#Marks_similar_to_European_punctuation. The characters that are relevant for mathjs are:
,,、,!!??;;::(())[[]]If there is indeed need for this, we can implement support for it in two ways:
parse.isDigit, introduce functions likeisParenthesisOpenwhich test for the English and Chinese variant of the character. We can also think though how to make sure that stringifying an expression keeps track on the originally used character. I'm not sure if this is worth the added complexity though.Any thoughts: