WebSafe 3.7github.com
|
|
🏠
Skip to content

Bug: C++WinRT does not correctly handles Chinese characters using Windows.Foundation.Uri #1424

@HO-COOH

Description

@HO-COOH

Version

2.0.240405.15

Summary

I have a uri with Chinese character and query string that needs to be parsed with Windows.Foundation.Uri. Using C++WinRT, it always returns me an empty result. But equivalent C# code does returns me expected result.

I have tried changing the file encoding to either UTF-8 and UTF-8 BOM, nothing worked.

Reproducible example

With C++WinRT, create a C++WinRT console application:

    winrt::Windows::Foundation::Uri uri{ LR"(myapp://open?file="C:/我.txt")" };
    winrt::Windows::Foundation::WwwFormUrlDecoder parsed{ uri.Query() };
    for (auto entry : parsed)
    {
        std::wcout << entry.Name().data() << L'\t' << entry.Value().data() << L'\n';
    }

With C#, create a UWP project:

            var uri = new Uri("myapp://open?file=\"C:/我.txt\"");
            var parsed = new WwwFormUrlDecoder(uri.Query);
            foreach (var entry in parsed)
            {
                Debug.WriteLine(entry);
            }

Expected behavior

C# result is expected:
image

Actual behavior

C++WinRT result:
image

Additional comments

Repro here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions