Skip to content

A valid Windows regional format corrupts decoder numbers and generated export filenames #913

Description

@guajun

Environment

  • DSView 1.3.2 from the DreamSourceLab download page
  • Windows 11 build 26200
  • Windows regional format selected through Settings: Chinese (Simplified, Hong Kong SAR) / zh-Hans-HK
  • DSView embeds Qt 5.14.1

Problem

Selecting the supported Windows regional format Chinese (Simplified, Hong Kong SAR) causes Windows to expose Chinese native digits (〇一二三四五六七八九). Numeric values throughout DSView then become unreadable CJK punctuation. Generated protocol-export filenames contain those punctuation code points as real NTFS filename characters, so this is not only a font-rendering problem.

This regional format was selected through the normal Windows Settings UI. It is not a manually edited or unsupported registry configuration, and an application should not require the user to change regional format in order to display protocol values correctly.

For example, a CAN export was created as:

decoder--〉」〇』〇》-〈〈〉〈〇「.csv

The intended session timestamp was:

decoder--260804-112105.csv

The substitution is deterministic:

0 -> U+3007 〇
1 -> U+3008 〈
2 -> U+3009 〉
3 -> U+300A 《
4 -> U+300B 》
5 -> U+300C 「
6 -> U+300D 」
7 -> U+300E 『
8 -> U+300F 』
9 -> U+3010 【

DSView/Qt appears to take the first native digit (, U+3007) as the zero digit and derive the remaining digits by adding 0 through 9. Chinese numeral characters are not contiguous in Unicode, so this produces punctuation rather than 一二三....

The Windows digit-substitution preference (NumShape) is 1 on both the affected and unaffected computers. According to Microsoft, value 1 means that no native digit substitution should be used. DSView nevertheless derives its displayed and persisted characters from the native-digit setting.

https://learn.microsoft.com/en-us/windows/win32/intl/locale-idigitsubstitution

The exported CSV payload itself is valid ASCII/UTF-8 and its decoded CAN data is correct. Only localized numeric presentation and the generated filename are affected.

Reproduction

  1. In Windows Settings, select the regional format Chinese (Simplified, Hong Kong SAR).
  2. Start DSView 1.3.2.
  3. Add a CAN decoder and open Decoder Options.
  4. Observe numeric fields such as the baud rate and sample point.
  5. Export the decoded protocol data and inspect the generated filename.

Comparison

Affected computer Unaffected computer
Windows build 26200 26200
Regional format zh-Hans-HK zh-CN
sNativeDigits 〇一二三四五六七八九 0123456789
NumShape 1 1
DSView executable Same SHA-256 Same SHA-256
Result CJK punctuation ASCII digits

Restoring sNativeDigits to 0123456789 and restarting DSView fixes both the decoder fields and newly generated filenames.

Expected behavior

Protocol parameters are machine values, so they should remain unambiguous and usable under every supported Windows regional format. A regional preference may affect presentation where appropriate, but it must not turn digits into punctuation or alter the actual characters persisted in a filesystem name.

Suggested fixes

  • Use an invariant locale for instrument numeric controls, while leaving normal translatable UI text localized.
  • Do not derive ten digits by assuming that the locale's native zero is followed by nine contiguous Unicode code points. Validate the complete native-digit table or fall back to ASCII digits.
  • Normalize generated filenames to invariant ASCII digits after returning from QFileDialog.
  • Add an automated test using the zh-Hans-HK regional format and the native-digit sequence above.

The timestamp helper and export-name call site are here:

QString Formatting::DateTimeToString(QDateTime tm, TimeStrigFormatType format)
{
int year = tm.date().year();
int month = tm.date().month();
int day = tm.date().day();
int hour = tm.time().hour();
int minute = tm.time().minute();
int second = tm.time().second();
char buffer[20];
switch (format)
{
case TimeStrigFormatType::TIME_STR_FORMAT_SHORT2: //"yyMMdd-hhmmss"
sprintf(buffer, "%02d%02d%02d-%02d%02d%02d", year%100, month, day, hour, minute, second);
break;
default: //yyyy-MM-dd hh:mm:ss
sprintf(buffer, "%04d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, second);
break;
}
return QString(buffer);

QString default_name = app.userHistory.protocolExportPath + "/" + "decoder-";
QString dateTimeString = Formatting::DateTimeToString(_session->get_session_time(), TimeStrigFormatType::TIME_STR_FORMAT_SHORT2);
default_name += "-" + dateTimeString;
QString file_name = QFileDialog::getSaveFileName(
this,
L_S(STR_PAGE_DLG, S_ID(IDS_DLG_EXPORT_DATA), "Export Data"),
default_name, filter,

I can provide screenshots, the affected filename, and the registry comparison if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions