KhronosGroup / KhronosGroup/OpenCOLLADA

Utf-8 encoded filename on Windows

Open
#548 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
679
Forks
260
PR merge metrics
No merged PRs in 30d

Description

- `COLLADABU::NativeString` has the option to accept a UTF-8 encoded string [1].
- This transforms utf-8 to utf-16 to CP_ACP [2]
- Through the StreamWriter constructor the `std::ofstream` is opened by calling `c_str()` [3].
- On my end this mostly ends up as question marks for characters outside of my native code page.

What is the proper way to open a UTF-8 (or otherwise unicode) file on Windows? There seems to be a way to open a file using `wchar_t*` [4] which I think is the sanest way to handle unicode files on Windows, although not very portable. But I can't seem to connect it to the StreamWriter which always defaults to `char*`.

[1] https://github.com/KhronosGroup/OpenCOLLADA/blob/ab61463df4cbe6535c0c0a1560d9b9c67225c55e/COLLADABaseUtils/include/COLLADABUNativeString.h#L34
[2] https://github.com/KhronosGroup/OpenCOLLADA/blob/ab61463df4cbe6535c0c0a1560d9b9c67225c55e/COLLADABaseUtils/src/COLLADABUNativeString.cpp#L46
[3] https://github.com/KhronosGroup/OpenCOLLADA/blob/ab61463df4cbe6535c0c0a1560d9b9c67225c55e/COLLADAStreamWriter/src/COLLADASWStreamWriter.cpp#L69
[4] https://github.com/KhronosGroup/OpenCOLLADA/blob/ab61463df4cbe6535c0c0a1560d9b9c67225c55e/common/libBuffer/include/CommonFWriteBufferFlusher.h#L84

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the filename through COLLADABUNativeString.cpp, COLLADASWStreamWriter.cpp, and CommonFWriteBufferFlusher.h, focusing on the UTF-8 to UTF-16 to CP_ACP conversion and the std::ofstream c_str() call. Compare the available wchar_t* opening path and determine a portable approach; done means Unicode filenames are preserved on Windows without disrupting other platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.