Skip to content
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

Fix invalid characters in speech to text result #1857

Merged
merged 2 commits into from
Jan 30, 2019
Merged

Fix invalid characters in speech to text result #1857

merged 2 commits into from
Jan 30, 2019

Conversation

dkakaie
Copy link
Contributor

@dkakaie dkakaie commented Jan 30, 2019

Default string in .NET uses UTF-16 causing invalid characters to appear as mentioned in here. This pull fixes the issue by returning the result as UTF-8.

@ghost
Copy link

ghost commented Jan 30, 2019

No Taskcluster jobs started for this pull request
The `allowPullRequests` configuration for this repository (in `.taskcluster.yml` on the
default branch) does not allow starting tasks for this pull request.

Copy link
Contributor

@reuben reuben left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I have a comment of comments (inline).

while (Marshal.ReadByte(res, len) != 0) ++len;
byte[] buffer = new byte[len];
Marshal.Copy(res, buffer, 0, buffer.Length);
return Encoding.UTF8.GetString(buffer);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these lines instead just be return Marshall.PtrToStringUTF8(res)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems no, there's no direct Marshal for UTF-8.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, looks like it was added in a version of .NET that's more recent than the one we use: https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.ptrtostringutf8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Current client is not .NET Core so we'll have to go with this unless we change framework.

@ghost
Copy link

ghost commented Jan 30, 2019

No Taskcluster jobs started for this pull request
The `allowPullRequests` configuration for this repository (in `.taskcluster.yml` on the
default branch) does not allow starting tasks for this pull request.

@reuben reuben merged commit e3bda9e into mozilla:master Jan 30, 2019
@lissyx lissyx added the bug label Jan 30, 2019
@lock
Copy link

lock bot commented Mar 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants