-
-
Notifications
You must be signed in to change notification settings - Fork 621
Add remove Utf8 BOM #394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release
Are you sure you want to change the base?
Add remove Utf8 BOM #394
Conversation
In the OBJ file if the first line starts with a invisible BOM char like:\uFEFFmtllib model.mtl the parsing of the textures does not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds handling for UTF-8 BOM characters at the start of OBJ/MTL files to ensure correct parsing of mtllib
and other tokens.
- Introduce
removeUtf8Bom
helper to strip BOM bytes if present. - Invoke BOM removal on each line before token parsing in
LoadMtl
andLoadObj
.
Comments suppressed due to low confidence (1)
tiny_obj_loader.h:2124
- The new BOM-removal behavior isn't covered by existing tests. Add unit tests for lines starting with
\uFEFF
to ensure this function works as expected.
linebuf = removeUtf8Bom(linebuf);
Please add reproducible test .obj/.mtl to |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add if (line_no == 1) removeUtf8Bom(linebuf) to obj aswell
@syoyo I added a unit test for removeUtf8Bom and a test with UTF-8 BOM encoded models. As Copilot suggested I also added the BOM check to the MTL file not only the obj file. Let me know if there are any further changes you want me to make. |
@paulbauriegel Thank you! Will be merged soon after the review. |
In the OBJ file if the first line starts with a invisible BOM char like: \uFEFFmtllib model.mtl
The parsing of the textures does not work in that case because of
if ((0 == strncmp(token, "mtllib", 6)) && IS_SPACE((token[6]))) {