Make MATLAB output in strict ASCII
이전 댓글 표시
MATLAB console output used high-ASCII sometimes, e.g. for its prompt ( » ). In R2025A it may output UTF8, e.g., for zpk() output:
z =
0×1 empty double column vector
p =
9.900494692205900e-01
k =
9.950657811787363e-03
This 'feature' is a nuisance when interchanging text with other programs. Is there a built-in function to convert these occasional UTF non-ASCII characters to a reasonable approximation in standard ASCII? ( like 'x' or '>>') ?
Or is this behavior to be considered a bug that will be fixed (there appear to be quite a few nuisance bugs in R2025a).
-marcel
댓글 수: 3
z = zeros(0,1)
The character used between the 0 and the 1 is the '×' character, U+00D7, decimal 215. This character only takes a single byte to represent in UTF-8. This character is present in most ISO-8896-* character sets, and most of the common Windows code pages (for example it is missing in Windows 1255 - Hebrew)
marcel hendrix
2025년 7월 6일
Walter Roberson
2025년 7월 6일
I was wrong, by the way, in saying that 0xD7 required only one byte in UTF-8.
답변 (1개)
Walter Roberson
2025년 7월 3일
0 개 추천
Is there a built-in function to convert these occasional UTF non-ASCII characters to a reasonable approximation in standard ASCII? ( like 'x' or '>>') ?
No, there is no built-in function for that purpose.
Any such hypothetical built-in function would have to deal with the problem of contention about what the replacements should be. For example should × be replaced with x or with * or with by or with times ? The answer is likely to depend on context -- in some places × should be replaced by x but in some places it should be replaced by *
댓글 수: 7
Walter Roberson
2025년 7월 3일
MATLAB console output used high-ASCII sometimes, e.g. for its prompt ( » ).
I have never ever observed MATLAB using » for its >> prompt.
What system Language setting are you using?
marcel hendrix
2025년 7월 4일
편집: marcel hendrix
2025년 7월 4일
Stephen23
2025년 7월 4일
It sounds like Windows applies some kind of "smart quotes" transformation to its console. In which case this would depend mostly on your OS locale and language settings.
Walter Roberson
2025년 7월 4일
As an experiment, you should have the C program write the text to a file, and later examine the bytes of the file. This will allow you to distinguish between "output by the program" compared to "as displayed in Windows console"
marcel hendrix
2025년 7월 4일
편집: marcel hendrix
2025년 7월 4일
Image Analyst
2025년 7월 4일
Can you post a screenshot?
Walter Roberson
2025년 7월 4일
The prompt ( » ) is $C2 $BB, so MATLAB appears to emit UTF-16
That is UTF-8 rather than UTF-16
카테고리
도움말 센터 및 File Exchange에서 Argument Definitions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!