How can I recognize automatically the List Separator in the Region and Languages settings?

4 ビュー (過去 30 日間)
Mauricio Toledo
Mauricio Toledo 2017 年 6 月 9 日
回答済み: Simon Hancock 2018 年 5 月 3 日
Hi, I want to make a .csv export in a Matlab tool. The tool can be used either by users using a List separator "," or ";". How can I get automatically the List separator of the user's computer, so that I can make a .csv export with this delimiter?
  1 件のコメント
Stephen23
Stephen23 2017 年 6 月 14 日
編集済み: Stephen23 2017 年 6 月 14 日
Most languages that use ; as the separator do so because they use , as the decimal radix marker (i.e. decimal point in English). Will you also try to convert the decimal radix marker to a comma?

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

回答 (2 件)

Arnav Mendiratta
Arnav Mendiratta 2017 年 6 月 13 日
This question has 2 parts:
1. How to get the delimiter from the Region and Languages settings?
  • I don't know of any Windows API that lets you do this. Maybe there are tools where you can directly query this. However, I am not sure. If you somehow have this within MATLAB you can save the file with this specific delimiter.
2. How to save a CSV file with this delimiter.
  • In any case, you need to specify what delimiter to use to save a file. Once you have access to this delimiter, you can use a simple if check to save the file in any supported format, such as dlmwrite .

Simon Hancock
Simon Hancock 2018 年 5 月 3 日
You can use the following Windows API to get the list seperator:
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, szBuf, sizeof(szBuf))
This could be called from a C-MEX file, returning a string to Matlab.

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by