Initialization of a wchar_t array with wmemset. Does encoding matter?












0















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));









share|improve this question




















  • 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
















0















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));









share|improve this question




















  • 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














0












0








0








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));









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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














  • 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








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












1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer


























  • 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











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
});


}
});














draft saved

draft discarded


















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









1














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.






share|improve this answer


























  • 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
















1














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.






share|improve this answer


























  • 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














1












1








1







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.






share|improve this answer















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.







share|improve this answer














share|improve this answer



share|improve this answer








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 '' 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



















  • 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

















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




















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to pass form data using jquery Ajax to insert data in database?

National Museum of Racing and Hall of Fame

Guess what letter conforming each word