Skip to content

Use UTF-8 for OpenAL string marshalling #2439

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

Merged
merged 1 commit into from
Apr 6, 2025
Merged

Conversation

Morilli
Copy link
Contributor

@Morilli Morilli commented Apr 4, 2025

Marshal.PtrToStringAnsi uses the system codepage which is problematic especially on windows. OpenAL returns UTF-8 strings which should be parsed as UTF-8.

Using the following test code:

var api = ALContext.GetApi();
api.TryGetExtension<EnumerateAll>(null, out var enumerateAll);
var deviceEnumerable = enumerateAll.GetStringList(GetEnumerateAllContextStringList.AllDevicesSpecifier);
foreach (var deviceName in deviceEnumerable)
{
    Console.WriteLine(deviceName);
}

with a non-utf-8 codepage and a device named test ドットネット, I get:

before:
OpenAL Soft on test ãƒ%ッãƒ^ãƒ?ッãƒ^ (Realtek High Definition Audio)

after (with proper console encoding configured):
OpenAL Soft on test ドットネット (Realtek High Definition Audio)

Copy link
Member

@Perksey Perksey left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Silk.NET Development Tracker Apr 6, 2025
@Perksey Perksey merged commit cd66e21 into dotnet:main Apr 6, 2025
3 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Silk.NET Development Tracker Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants