Initialization of a wchar_t array with wmemset. Does encoding matter?
How do I correctly initialize a wchar_t array with wmemset?
Should I use '' or L'' ? Does it matter?
does the encoding matter ? (unicode, ISO####)
eg
wchar_t arr[20];
wmemset(arr, '', sizeof(arr));
c++ wchar-t
add a comment |
How do I correctly initialize a wchar_t array with wmemset?
Should I use '' or L'' ? Does it matter?
does the encoding matter ? (unicode, ISO####)
eg
wchar_t arr[20];
wmemset(arr, '', sizeof(arr));
c++ wchar-t
1
Hadn't heard ofwmemsetbefore. Looking at the documentation, the third parameter is the number of characters not bytes so usingsizeofis wrong.
– Mark Ransom
May 14 '15 at 15:12
add a comment |
How do I correctly initialize a wchar_t array with wmemset?
Should I use '' or L'' ? Does it matter?
does the encoding matter ? (unicode, ISO####)
eg
wchar_t arr[20];
wmemset(arr, '', sizeof(arr));
c++ wchar-t
How do I correctly initialize a wchar_t array with wmemset?
Should I use '' or L'' ? Does it matter?
does the encoding matter ? (unicode, ISO####)
eg
wchar_t arr[20];
wmemset(arr, '', sizeof(arr));
c++ wchar-t
c++ wchar-t
edited Nov 21 '18 at 5:25
Cœur
18.9k9112154
18.9k9112154
asked May 14 '15 at 15:09
thahgrthahgr
137215
137215
1
Hadn't heard ofwmemsetbefore. Looking at the documentation, the third parameter is the number of characters not bytes so usingsizeofis wrong.
– Mark Ransom
May 14 '15 at 15:12
add a comment |
1
Hadn't heard ofwmemsetbefore. Looking at the documentation, the third parameter is the number of characters not bytes so usingsizeofis wrong.
– Mark Ransom
May 14 '15 at 15:12
1
1
Hadn't heard of
wmemset before. Looking at the documentation, the third parameter is the number of characters not bytes so using sizeof is wrong.– Mark Ransom
May 14 '15 at 15:12
Hadn't heard of
wmemset before. Looking at the documentation, the third parameter is the number of characters not bytes so using sizeof is wrong.– Mark Ransom
May 14 '15 at 15:12
add a comment |
1 Answer
1
active
oldest
votes
You need to use the L'' form to get a wchar_t type, although any value that fits within a char (such as '') will be automatically converted using the usual integer promotions. See character literal or C++ Character Literals.
It's unclear to me what code page the source will be interpreted in. To be safe, it's best to use a L'u20ac' or L'U000020ac' form to specify characters outside of the ASCII character set.
thanks for your answer, to help me clarify, I am talking about specifically wmemset, your anwers refer to that? you say that the trailing zero will be the same with''andL''?
– thahgr
May 15 '15 at 7:55
Yes, that's exactly what I'm saying. The parameter towmemsetis awchar_t, and if you give acharinstead it will be promoted so the result is the same.
– Mark Ransom
May 15 '15 at 12:53
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%2f30240823%2finitialization-of-a-wchar-t-array-with-wmemset-does-encoding-matter%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
You need to use the L'' form to get a wchar_t type, although any value that fits within a char (such as '') will be automatically converted using the usual integer promotions. See character literal or C++ Character Literals.
It's unclear to me what code page the source will be interpreted in. To be safe, it's best to use a L'u20ac' or L'U000020ac' form to specify characters outside of the ASCII character set.
thanks for your answer, to help me clarify, I am talking about specifically wmemset, your anwers refer to that? you say that the trailing zero will be the same with''andL''?
– thahgr
May 15 '15 at 7:55
Yes, that's exactly what I'm saying. The parameter towmemsetis awchar_t, and if you give acharinstead it will be promoted so the result is the same.
– Mark Ransom
May 15 '15 at 12:53
add a comment |
You need to use the L'' form to get a wchar_t type, although any value that fits within a char (such as '') will be automatically converted using the usual integer promotions. See character literal or C++ Character Literals.
It's unclear to me what code page the source will be interpreted in. To be safe, it's best to use a L'u20ac' or L'U000020ac' form to specify characters outside of the ASCII character set.
thanks for your answer, to help me clarify, I am talking about specifically wmemset, your anwers refer to that? you say that the trailing zero will be the same with''andL''?
– thahgr
May 15 '15 at 7:55
Yes, that's exactly what I'm saying. The parameter towmemsetis awchar_t, and if you give acharinstead it will be promoted so the result is the same.
– Mark Ransom
May 15 '15 at 12:53
add a comment |
You need to use the L'' form to get a wchar_t type, although any value that fits within a char (such as '') will be automatically converted using the usual integer promotions. See character literal or C++ Character Literals.
It's unclear to me what code page the source will be interpreted in. To be safe, it's best to use a L'u20ac' or L'U000020ac' form to specify characters outside of the ASCII character set.
You need to use the L'' form to get a wchar_t type, although any value that fits within a char (such as '') will be automatically converted using the usual integer promotions. See character literal or C++ Character Literals.
It's unclear to me what code page the source will be interpreted in. To be safe, it's best to use a L'u20ac' or L'U000020ac' form to specify characters outside of the ASCII character set.
edited May 14 '15 at 15:38
answered May 14 '15 at 15:24
Mark RansomMark Ransom
226k30286509
226k30286509
thanks for your answer, to help me clarify, I am talking about specifically wmemset, your anwers refer to that? you say that the trailing zero will be the same with''andL''?
– thahgr
May 15 '15 at 7:55
Yes, that's exactly what I'm saying. The parameter towmemsetis awchar_t, and if you give acharinstead it will be promoted so the result is the same.
– Mark Ransom
May 15 '15 at 12:53
add a comment |
thanks for your answer, to help me clarify, I am talking about specifically wmemset, your anwers refer to that? you say that the trailing zero will be the same with''andL''?
– thahgr
May 15 '15 at 7:55
Yes, that's exactly what I'm saying. The parameter towmemsetis awchar_t, and if you give acharinstead it will be promoted so the result is the same.
– Mark Ransom
May 15 '15 at 12:53
thanks for your answer, to help me clarify, I am talking about specifically wmemset, your anwers refer to that? you say that the trailing zero will be the same with
'' and L'' ?– thahgr
May 15 '15 at 7:55
thanks for your answer, to help me clarify, I am talking about specifically wmemset, your anwers refer to that? you say that the trailing zero will be the same with
'' and L'' ?– thahgr
May 15 '15 at 7:55
Yes, that's exactly what I'm saying. The parameter to
wmemset is a wchar_t, and if you give a char instead it will be promoted so the result is the same.– Mark Ransom
May 15 '15 at 12:53
Yes, that's exactly what I'm saying. The parameter to
wmemset is a wchar_t, and if you give a char instead it will be promoted so the result is the same.– Mark Ransom
May 15 '15 at 12:53
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%2f30240823%2finitialization-of-a-wchar-t-array-with-wmemset-does-encoding-matter%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
Hadn't heard of
wmemsetbefore. Looking at the documentation, the third parameter is the number of characters not bytes so usingsizeofis wrong.– Mark Ransom
May 14 '15 at 15:12