Skip to content

fix: Unicode characters stripped from generated file names#163

Merged
Pushpavel merged 4 commits into
Pushpavel:mainfrom
JoonHyuk0331:fix-unicode-file-name
Feb 22, 2026
Merged

fix: Unicode characters stripped from generated file names#163
Pushpavel merged 4 commits into
Pushpavel:mainfrom
JoonHyuk0331:fix-unicode-file-name

Conversation

@JoonHyuk0331
Copy link
Copy Markdown
Contributor

Problem

autocp파싱안됨
  1. Problem.getDefaultName() directly called defaultConversion, which strips all non-ASCII characters via [^0-9a-zA-Z_]. This bypassed the existing fallback chain in getValidFileName that already supports Unicode through specialCharacterFiltering and unicodeWhiteListConversion. As a result, problem names like "한국어 문제 A" became "__A".

  2. Space-to-underscore conversion only existed in defaultConversion (step 3 of the fallback chain). Since specialCharacterFiltering (step 1) succeeds on all modern OS, getValidFileName never reached step 3, leaving spaces unconverted in file names.

Root Cause

1-> getDefaultName() called defaultConversion directly instead of going through the getValidFileName fallback chain, making specialCharacterFiltering and unicodeWhiteListConversion effectively dead code for default file name generation.

2-> getValidFileName delegated space handling entirely to defaultConversion, but spaces are valid path characters, so steps 1 and 2 never threw InvalidPathException and step 3 was never reached.

What Changed

File: DefaultFileGenerator.kt

Change: getValidFileName: protected → internal
Why: Allow getDefaultName() to call it via instance without duplicating fallback logic. No subclass overrides this method.

File: problemGatheringDialog.kt

Change: getDefaultName(): defaultConversion(name) → DefaultFileGenerator(project).getValidFileName(name)
Why: Use the proper fallback chain so Unicode characters are preserved


File: DefaultFileGenerator.kt

Change: Added name.replace(' ', '_') after fallback chain in getValidFileName
Why: Ensure space-to-underscore conversion applies regardless of which fallback step succeeds

Test

Test by using ./gradlew runIde -PplatformType=PC -PplatformVersion=2025.1
autocp개선유니코드

Copy link
Copy Markdown
Owner

@Pushpavel Pushpavel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JoonHyuk0331, great breakdown in the PR. Problem.getDefaultName() is a mistake, we don't need to convert the problem name in showProblemGatheringDialog at all, It anyways is going to be converted based on file extension when the file is getting generated. So, I think just removing Problem.getDefaultName() and using problemNames = MutableList(problems.size) { problems[it].name } should work fine

@JoonHyuk0331
Copy link
Copy Markdown
Contributor Author

JoonHyuk0331 commented Feb 13, 2026

thx for the review!
I understood, the dialog doesn't need to convert the name at all since getValidFileName handles it during file generation.

I've removed Problem.getDefaultName() entirely and changed the dialog to use problems[it].name directly. Also reverted getValidFileName visibility back to protected since it's no longer called externally.

remaining change:

in DefaultFileGenerator is adding replace(' ', '_') at the end of getValidFileName, so that space-to-underscore conversion applies regardless of which fallback step succeeds (previously it only existed in defaultConversion).
before
개선전저장이상하게
after
pr리뷰개선
2.
Since the dialog no longer passes the name through defaultConversion, users can now see the original Unicode problem name as-is in both
before
image
after
image

@JoonHyuk0331
Copy link
Copy Markdown
Contributor Author

Hi @Pushpavel, I've implemented the requested changes. Could you please review it again? Thanks!

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...pavel/autocp/gather/base/problemGatheringDialog.kt 0.00% 2 Missing ⚠️
...avel/autocp/gather/filegen/DefaultFileGenerator.kt 0.00% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Files with missing lines Coverage Δ
...pavel/autocp/gather/base/problemGatheringDialog.kt 0.00% <0.00%> (ø)
...avel/autocp/gather/filegen/DefaultFileGenerator.kt 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Pushpavel Pushpavel merged commit 098cf89 into Pushpavel:main Feb 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants