Why is std::filesystem::u8path deprecated in c++20?
Introduced in c++17, std::filesystem::u8path
seems to be deprecated in c++20.
What is the reason for this choice? What should I use in c++17? What should I use in c++20?
c++ c++20
|
show 1 more comment
Introduced in c++17, std::filesystem::u8path
seems to be deprecated in c++20.
What is the reason for this choice? What should I use in c++17? What should I use in c++20?
c++ c++20
1
Not sure why it was ever there, it seems likestd::filesystem::path
has a constructor that performs the same as that function.
– Fantastic Mr Fox
Jan 2 at 9:40
1
From path page on cppreference : “For portable pathname generation from Unicode strings, see u8path”
– Guillaume Gris
Jan 2 at 9:45
Hmmm, true. But it also says: If the source character type is char, the encoding of the source is assumed to be the native narrow encoding (for constructor 6). I am pretty sure this covers unicode where unicode is the native format. It says the same in u8path: If path::value_type is char and native encoding is UTF-8, constructs a path directly. Maybe the note is unnecessary and the path constructor does the right thing?
– Fantastic Mr Fox
Jan 2 at 9:52
1
Native narrow encoding is UTF-8 on Unix systems, on Windows, it's more complicated according to this question: stackoverflow.com/questions/4649388/…
– Guillaume Gris
Jan 2 at 9:59
1
@cpplearner that should be an answer, not a comment
– Caleth
Jan 2 at 10:54
|
show 1 more comment
Introduced in c++17, std::filesystem::u8path
seems to be deprecated in c++20.
What is the reason for this choice? What should I use in c++17? What should I use in c++20?
c++ c++20
Introduced in c++17, std::filesystem::u8path
seems to be deprecated in c++20.
What is the reason for this choice? What should I use in c++17? What should I use in c++20?
c++ c++20
c++ c++20
asked Jan 2 at 9:35


Guillaume GrisGuillaume Gris
1,141922
1,141922
1
Not sure why it was ever there, it seems likestd::filesystem::path
has a constructor that performs the same as that function.
– Fantastic Mr Fox
Jan 2 at 9:40
1
From path page on cppreference : “For portable pathname generation from Unicode strings, see u8path”
– Guillaume Gris
Jan 2 at 9:45
Hmmm, true. But it also says: If the source character type is char, the encoding of the source is assumed to be the native narrow encoding (for constructor 6). I am pretty sure this covers unicode where unicode is the native format. It says the same in u8path: If path::value_type is char and native encoding is UTF-8, constructs a path directly. Maybe the note is unnecessary and the path constructor does the right thing?
– Fantastic Mr Fox
Jan 2 at 9:52
1
Native narrow encoding is UTF-8 on Unix systems, on Windows, it's more complicated according to this question: stackoverflow.com/questions/4649388/…
– Guillaume Gris
Jan 2 at 9:59
1
@cpplearner that should be an answer, not a comment
– Caleth
Jan 2 at 10:54
|
show 1 more comment
1
Not sure why it was ever there, it seems likestd::filesystem::path
has a constructor that performs the same as that function.
– Fantastic Mr Fox
Jan 2 at 9:40
1
From path page on cppreference : “For portable pathname generation from Unicode strings, see u8path”
– Guillaume Gris
Jan 2 at 9:45
Hmmm, true. But it also says: If the source character type is char, the encoding of the source is assumed to be the native narrow encoding (for constructor 6). I am pretty sure this covers unicode where unicode is the native format. It says the same in u8path: If path::value_type is char and native encoding is UTF-8, constructs a path directly. Maybe the note is unnecessary and the path constructor does the right thing?
– Fantastic Mr Fox
Jan 2 at 9:52
1
Native narrow encoding is UTF-8 on Unix systems, on Windows, it's more complicated according to this question: stackoverflow.com/questions/4649388/…
– Guillaume Gris
Jan 2 at 9:59
1
@cpplearner that should be an answer, not a comment
– Caleth
Jan 2 at 10:54
1
1
Not sure why it was ever there, it seems like
std::filesystem::path
has a constructor that performs the same as that function.– Fantastic Mr Fox
Jan 2 at 9:40
Not sure why it was ever there, it seems like
std::filesystem::path
has a constructor that performs the same as that function.– Fantastic Mr Fox
Jan 2 at 9:40
1
1
From path page on cppreference : “For portable pathname generation from Unicode strings, see u8path”
– Guillaume Gris
Jan 2 at 9:45
From path page on cppreference : “For portable pathname generation from Unicode strings, see u8path”
– Guillaume Gris
Jan 2 at 9:45
Hmmm, true. But it also says: If the source character type is char, the encoding of the source is assumed to be the native narrow encoding (for constructor 6). I am pretty sure this covers unicode where unicode is the native format. It says the same in u8path: If path::value_type is char and native encoding is UTF-8, constructs a path directly. Maybe the note is unnecessary and the path constructor does the right thing?
– Fantastic Mr Fox
Jan 2 at 9:52
Hmmm, true. But it also says: If the source character type is char, the encoding of the source is assumed to be the native narrow encoding (for constructor 6). I am pretty sure this covers unicode where unicode is the native format. It says the same in u8path: If path::value_type is char and native encoding is UTF-8, constructs a path directly. Maybe the note is unnecessary and the path constructor does the right thing?
– Fantastic Mr Fox
Jan 2 at 9:52
1
1
Native narrow encoding is UTF-8 on Unix systems, on Windows, it's more complicated according to this question: stackoverflow.com/questions/4649388/…
– Guillaume Gris
Jan 2 at 9:59
Native narrow encoding is UTF-8 on Unix systems, on Windows, it's more complicated according to this question: stackoverflow.com/questions/4649388/…
– Guillaume Gris
Jan 2 at 9:59
1
1
@cpplearner that should be an answer, not a comment
– Caleth
Jan 2 at 10:54
@cpplearner that should be an answer, not a comment
– Caleth
Jan 2 at 10:54
|
show 1 more comment
1 Answer
1
active
oldest
votes
Because, thanks to the existence of char8_t
, this will work:
path p(u8"A/utf8/path");
u8path
existed to allow the detection of the difference between a UTF-8 string and a narrow character string. But since C++20 will give us an actual type for that, it is no longer necessary.
What should I use in c++17?
Use u8path
. Deprecation does not mean removed or inaccessible. It merely means subject to eventual removal.
At present, in C++20 u8path(u8"A/UTF8/String")
will fail to compile in C++20 due to u8
now creating a char8_t
string. But C++20 may be getting a change to u8path
that takes char8_t
strings.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54004000%2fwhy-is-stdfilesystemu8path-deprecated-in-c20%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Because, thanks to the existence of char8_t
, this will work:
path p(u8"A/utf8/path");
u8path
existed to allow the detection of the difference between a UTF-8 string and a narrow character string. But since C++20 will give us an actual type for that, it is no longer necessary.
What should I use in c++17?
Use u8path
. Deprecation does not mean removed or inaccessible. It merely means subject to eventual removal.
At present, in C++20 u8path(u8"A/UTF8/String")
will fail to compile in C++20 due to u8
now creating a char8_t
string. But C++20 may be getting a change to u8path
that takes char8_t
strings.
add a comment |
Because, thanks to the existence of char8_t
, this will work:
path p(u8"A/utf8/path");
u8path
existed to allow the detection of the difference between a UTF-8 string and a narrow character string. But since C++20 will give us an actual type for that, it is no longer necessary.
What should I use in c++17?
Use u8path
. Deprecation does not mean removed or inaccessible. It merely means subject to eventual removal.
At present, in C++20 u8path(u8"A/UTF8/String")
will fail to compile in C++20 due to u8
now creating a char8_t
string. But C++20 may be getting a change to u8path
that takes char8_t
strings.
add a comment |
Because, thanks to the existence of char8_t
, this will work:
path p(u8"A/utf8/path");
u8path
existed to allow the detection of the difference between a UTF-8 string and a narrow character string. But since C++20 will give us an actual type for that, it is no longer necessary.
What should I use in c++17?
Use u8path
. Deprecation does not mean removed or inaccessible. It merely means subject to eventual removal.
At present, in C++20 u8path(u8"A/UTF8/String")
will fail to compile in C++20 due to u8
now creating a char8_t
string. But C++20 may be getting a change to u8path
that takes char8_t
strings.
Because, thanks to the existence of char8_t
, this will work:
path p(u8"A/utf8/path");
u8path
existed to allow the detection of the difference between a UTF-8 string and a narrow character string. But since C++20 will give us an actual type for that, it is no longer necessary.
What should I use in c++17?
Use u8path
. Deprecation does not mean removed or inaccessible. It merely means subject to eventual removal.
At present, in C++20 u8path(u8"A/UTF8/String")
will fail to compile in C++20 due to u8
now creating a char8_t
string. But C++20 may be getting a change to u8path
that takes char8_t
strings.
edited Jan 27 at 22:49
answered Jan 2 at 14:32
Nicol BolasNicol Bolas
290k34481657
290k34481657
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54004000%2fwhy-is-stdfilesystemu8path-deprecated-in-c20%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Not sure why it was ever there, it seems like
std::filesystem::path
has a constructor that performs the same as that function.– Fantastic Mr Fox
Jan 2 at 9:40
1
From path page on cppreference : “For portable pathname generation from Unicode strings, see u8path”
– Guillaume Gris
Jan 2 at 9:45
Hmmm, true. But it also says: If the source character type is char, the encoding of the source is assumed to be the native narrow encoding (for constructor 6). I am pretty sure this covers unicode where unicode is the native format. It says the same in u8path: If path::value_type is char and native encoding is UTF-8, constructs a path directly. Maybe the note is unnecessary and the path constructor does the right thing?
– Fantastic Mr Fox
Jan 2 at 9:52
1
Native narrow encoding is UTF-8 on Unix systems, on Windows, it's more complicated according to this question: stackoverflow.com/questions/4649388/…
– Guillaume Gris
Jan 2 at 9:59
1
@cpplearner that should be an answer, not a comment
– Caleth
Jan 2 at 10:54