widechar

How does gcc decide the wide character set when calling `mbtowc()`?

倖福魔咒の 提交于 2021-02-07 19:33:30
问题 According to the gcc manual, the option -fwide-exec-charset specifies the wide character set of wide string and character constants at compile time. But what is the wide character set when converting a multi-byte character to a wide character by calling mbtowc() at run time? The POSIX standard says that the character set of multi-byte characters is determined by the LC_CTYPE category of the current locale, but says nothing about the wide character set. I don't have a C standard at hand now so

is there an R code for the following data wrangling and transformation

纵然是瞬间 提交于 2021-02-05 10:40:54
问题 I have the following data set id<-c(1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4) s02<-c(001,002,003,004,001,002,003,004,005,001,002,003,004,005,006,007,001,002,003,004,005,006,007,008,009,010,011,012,013,014,015,016,017,018,019,020,021,022,023,024,025,026,027,028,029) dat1<-data.frame(id,s02) I would wish to create a data set based on this dat1. I would wish to have an R code that creates n s02 automatically as s02__0, s02__1, s02__2, s02__3, s02_

String conversion from System::String ^ to const wchar_t *

人走茶凉 提交于 2021-02-04 08:12:22
问题 I'm trying to open a file using a string parameter, however I'm getting the following error: error C2664: 'void std::basic_ifstream<_Elem,_Traits>::open(const wchar_t *,std::ios_base::openmode,int)' : cannot convert parameter 1 from 'System::String ^' to 'const wchar_t *' How do you convert System::String ^ to const wchar_t * ? 回答1: As Hans points out, simple conversion is necessary. It would look similar to the following: System::String ^str = L"Blah Blah"; pin_ptr<const wchar_t>

String conversion from System::String ^ to const wchar_t *

▼魔方 西西 提交于 2021-02-04 08:12:06
问题 I'm trying to open a file using a string parameter, however I'm getting the following error: error C2664: 'void std::basic_ifstream<_Elem,_Traits>::open(const wchar_t *,std::ios_base::openmode,int)' : cannot convert parameter 1 from 'System::String ^' to 'const wchar_t *' How do you convert System::String ^ to const wchar_t * ? 回答1: As Hans points out, simple conversion is necessary. It would look similar to the following: System::String ^str = L"Blah Blah"; pin_ptr<const wchar_t>

is there an R code for converting from wide to long when you have more than 1 unique id in R?

醉酒当歌 提交于 2021-01-28 22:08:22
问题 I have the following data that i want to convert from wide to long. id_1<-c(1,2,2,2) s02.0<-c(1,1,4,7) s02.1<-c(2,2,5,8) s02.2<-c(NA,3,6,NA) id_2<-c(1,1,2,3) df1<-data.frame(id_1,s02.0,s02.1,s02.2,id_2) I would wish to have the following output based on two unique ids, and added new variable say n, that defines the position of 's02' in each row id_1<-c(1,1,1,2,2,2,2,2,2,2,2,2) id_2<-c(1,1,1,1,1,1,2,2,2,3,3,3) s02<-c(1,2,NA,1,2,3,4,5,6,7,8,NA) n<-c(1,2,3,1,2,3,1,2,3,1,2,3) df2<-data.frame(id_1

is there an R code for converting from wide to long when you have more than 1 unique id in R?

霸气de小男生 提交于 2021-01-28 21:40:30
问题 I have the following data that i want to convert from wide to long. id_1<-c(1,2,2,2) s02.0<-c(1,1,4,7) s02.1<-c(2,2,5,8) s02.2<-c(NA,3,6,NA) id_2<-c(1,1,2,3) df1<-data.frame(id_1,s02.0,s02.1,s02.2,id_2) I would wish to have the following output based on two unique ids, and added new variable say n, that defines the position of 's02' in each row id_1<-c(1,1,1,2,2,2,2,2,2,2,2,2) id_2<-c(1,1,1,1,1,1,2,2,2,3,3,3) s02<-c(1,2,NA,1,2,3,4,5,6,7,8,NA) n<-c(1,2,3,1,2,3,1,2,3,1,2,3) df2<-data.frame(id_1

How do you safely declare a 16-bit string literal in C?

我只是一个虾纸丫 提交于 2020-08-07 03:40:37
问题 I'm aware that there is already a standard method by prefixing with L : wchar_t *test_literal = L"Test"; The problem is that wchar_t is not guaranteed to be 16-bits, but for my project, I need a 16-bit wchar_t . I'd also like to avoid the requirement of passing -fshort-wchar . So, is there any prefix for C (not C++) that will allow me to declare a UTF-16 string literal? 回答1: So, is there any prefix for C (not C++) that will allow me to declare a UTF-16 string literal? Almost, but not quite.

Why is © (the copyright symbol) replaced with (C) when using wprintf?

两盒软妹~` 提交于 2020-04-10 09:09:47
问题 When I try to print the copyright symbol © with printf or write , it works just fine: #include <stdio.h> int main(void) { printf("©\n"); } #include <unistd.h> int main(void) { write(1, "©\n", 3); } Output: © But when I try to print it with wprintf , I get (C) : #include <stdio.h> #include <wchar.h> int main(void) { wprintf(L"©\n"); } Output: (C) It's fixed when I add a call to setlocale , though: #include <stdio.h> #include <wchar.h> #include <locale.h> int main(void) { setlocale(LC_ALL, "");

Why is © (the copyright symbol) replaced with (C) when using wprintf?

有些话、适合烂在心里 提交于 2020-04-10 09:05:56
问题 When I try to print the copyright symbol © with printf or write , it works just fine: #include <stdio.h> int main(void) { printf("©\n"); } #include <unistd.h> int main(void) { write(1, "©\n", 3); } Output: © But when I try to print it with wprintf , I get (C) : #include <stdio.h> #include <wchar.h> int main(void) { wprintf(L"©\n"); } Output: (C) It's fixed when I add a call to setlocale , though: #include <stdio.h> #include <wchar.h> #include <locale.h> int main(void) { setlocale(LC_ALL, "");