ASCII characters in code?

I have a little problem with the display of some characters in my matlab code. The header of data i read from a text file contains special characters, which i need to write down into my code. E.g. one column has the Name "T / °C". Now every time i close and reopen Matlab, the parts in my code are displayd like this: "T / �C". So everyday i have to replace all occurances of this character, and of course it is not the only character. Is there a way to solve this. I did not find any setting in the preferences.
Thank you!

6 件のコメント

Dyuman Joshi
Dyuman Joshi 2024 年 4 月 25 日
How are you reading the data?
Also, could you please share a sample file so that we can test and reproduce the issue you are facing? Use the paperclip button to attach.
Luca
Luca 2024 年 4 月 25 日
I am reading the data via readtable, but that is not the issue. The problem is that the special characters in the Code itself are changed to � every time i restart matlab. To change the names of the data columns is not possible.
Fangjun Jiang
Fangjun Jiang 2024 年 4 月 25 日
編集済み: Fangjun Jiang 2024 年 4 月 25 日
I remember having this problem before but it has been long gone. Are you using MATLAB Editor in R2023b (which I think should not have this problem anymore), or a different editor? It is likely more related to OS. Check your OS region and language settings. Also, try to save the file (.m for example) to different encoding (UTF-8, windows-1252). You have that option when save the file.
Luca
Luca 2024 年 4 月 26 日
I use the R2023b Editor. Files are saved in UTF-8 encoding. When i type feature('locale') in the command window, the encoding is 'windows-1252'. Do i have to change that to UTF-8 or should that work?
Walter Roberson
Walter Roberson 2024 年 4 月 26 日
You should change the encoding to UTF-8

サインインしてコメントする。

回答 (1 件)

Pooja Kumari
Pooja Kumari 2024 年 4 月 25 日

0 投票

Hello,
I think this typically suggests that MATLAB is misinterpreting the encoding format of your script files, especially if those files are saved in an encoding that accommodates special characters, such as UTF-8, but MATLAB seems to be reading them using an alternative encoding specification.

カテゴリ

ヘルプ センター および File ExchangeWorkspace Variables and MAT Files についてさらに検索

製品

リリース

R2023b

質問済み:

2024 年 4 月 25 日

コメント済み:

2024 年 4 月 26 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by