search for: translatechar

Displaying 20 results from an estimated 35 matches for "translatechar".

2017 Jun 11
1
translateChar in NewName in bind.c
...ically copied from 'tag'. Could the whole thing there be just the following? ans = tag; It seems to me that it can also replace ans = R_BlankString; in 'else'; so, else if (*CHAR(tag)) and else can be merged to be just else . -------------------------------------------- Subject: translateChar in NewName in bind.c To: r-devel at r-project.org Date: Saturday, 10 June, 2017, 9:14 PM In function 'NewName' in bind.c (https://svn.r-project.org/R/trunk/src/main/bind.c), in else if (*CHAR(base)) , 'translateChar' is used. Should it be 'translateCharUTF8' instead?...
2017 Aug 01
0
translateChar in NewName in bind.c
...re now more efficient in constructing the names(.) of their return value, ...." However, currently, the NEWS item is for R-devel, not R 3.4.1 patched. -------------------------------------------- On Mon, 31/7/17, Martin Maechler <maechler at stat.math.ethz.ch> wrote: Subject: Re: [Rd] translateChar in NewName in bind.c Cc: r-devel at r-project.org Date: Monday, 31 July, 2017, 8:38 PM >>>>> Suharto Anggono Suharto Anggono via R-devel <r-devel at r-project.org> >>>>> on Sun, 30 Jul 2017 14:57:53 +0000 writes: > R devel's bind.c has been p...
2011 Mar 18
1
[Patch suggestion] Adding 3rd arg to tempfile() to set extension
...ileext is optional and defaults to "" so no test for vector*/ + if (n3 != 1) + error(_("only single argument for end-of-filename pattern supported")); slen = (n1 > n2) ? n1 : n2; PROTECT(ans = allocVector(STRSXP, slen)); for(i = 0; i < slen; i++) { tn = translateChar( STRING_ELT( pattern , i%n1 ) ); td = translateChar( STRING_ELT( tempdir , i%n2 ) ); + te = translateChar( STRING_ELT( fileext , 0 ) ); /* try to get a new file name */ tm = R_tmpnam(tn, td); - SET_STRING_ELT(ans, i, mkChar(tm)); + if (0 != strlen(te)) { + /* append optional extension, or...
2007 Sep 13
1
chartr better
...nc < 0) error(_("invalid multibyte string 'old'")); wc = (wchar_t *) R_AllocStringBuffer((nc+1)*sizeof(wchar_t), &cbuff); mbstowcs(wc, s, nc + 1); + wtr_build_spec(wc, trs_cnt); /* use count only */ wtr_build_spec(wc, trs_old); s = translateChar(STRING_ELT(_new, 0)); @@ -2096,38 +2111,54 @@ /* Initialize the pointers for walking through the old and new wtr_spec lists and retrieving the next chars from the lists. */ + trs_cnt_ptr = Calloc(1, struct wtr_spec *); + *trs_cnt_ptr = trs_cnt->next; +...
2020 Jun 07
5
use of the tcltk package crashes R 4.0.1 for Windows
...Anyways, Free() is just free() with a check that we're not freeing a null pointer, followed by setting the pointer to NULL. At that point of tcltk.c, we have for (objc = i = 0; i < length(avec); i++){ const char *s; char *tmp; if (!isNull(nm) && strlen(s = translateChar(STRING_ELT(nm, i)))){ // tmp = calloc(strlen(s)+2, sizeof(char)); tmp = Calloc(strlen(s)+2, char); *tmp = '-'; strcpy(tmp+1, s); objv[objc++] = Tcl_NewStringObj(tmp, -1); free(tmp); } if (!isNull(t = VE...
2020 Jun 07
3
[External] Re: use of the tcltk package crashes R 4.0.1 for Windows
...hat we're not freeing a null pointer, followed by setting the pointer to NULL. At that point of tcltk.c, we have > > > > for (objc = i = 0; i < length(avec); i++){ > > const char *s; > > char *tmp; > > if (!isNull(nm) && strlen(s = translateChar(STRING_ELT(nm, i)))){ > > // tmp = calloc(strlen(s)+2, sizeof(char)); > > tmp = Calloc(strlen(s)+2, char); > > *tmp = '-'; > > strcpy(tmp+1, s); > > objv[objc++] = Tcl_NewStringObj(tmp, -1); > >...
2017 Jun 30
1
Rprintf expected encoding
...I found an earlier thread about this (http://r.789695.n4.nabble.com/How-to-print-UTF-8-encoded-strings-from-a-C-routine-to-R-s-output-td4724337.html) but it wasn't very helpful. If I want to print a UTF-8 string, I can do one of the following: 1) Send native data via Rprintf("%s", translateChar(str)); 2) Send UTF-8 data via Rprintf("%s", translateCharUTF8(str)); If Rprintf is sending its output to stdout, then (1) seems like the correct option. If Rprintf is sending to a file connection with encoding set to UTF-8 (for example, after a call to sink(file(..., encoding="U...
2008 Jan 27
0
Character encodings and packages
...be declared, and console input in suitable locales is also recognized. New function Encoding() can read or set the declared encodings for a character vector. Whereas R itself is careful to make use of this, I see very little recognition of it in packages -- which need to be making use of translateChar() rather than CHAR(): see the 'Writing R Extensions' manual. (I see it used in only one package, and that mainly in a copy of base R code.) This will become more important as time goes by and more ways are introduced to generate marked data. In particular, in R 2.7.0 under Windows ...
2017 May 24
1
reg-tests-1d.R fails in r72721
...uot;~/", filename)) == + paste0(path.expand("~/"), filename)) Error: path.expand(paste0("~/", filename)) == paste0(path.expand("~/"), .... is not TRUE Execution halted The problem is that path.expand(), or do_pathexpand() for non-windoze calls translateChar() which in turn calls translateToNative() which is unknown to make check (but not to R --vanilla) under my setup. Once it is unknown, there seems to be no way to force an encoding: > ## path.expand shouldn't translate to local encoding PR#17120 > filename <- "\U9b3c.R" >...
2013 Mar 01
1
.Call interface: Use R SEXP as C mutable *char
Dear R Developers, DISCLAIMER: I am new to package development in R and new to this list. I am trying to do something along the lines of: SEXP test_fun (SEXP filename) { const char *inputfile = translateChar(STRING_ELT(filename, 0)); int abc = some_function(inputfile); ... } The code compiles fine, but I get a warning: "passing argument of 'some_function' discards qualifiers from pointer target type" I read up on my issue and found this posting: https://stat.ethz.ch/pipermail/r-...
2017 May 09
1
source(), parse(), and foreign UTF-8 characters
...edback you >> might have. >> >> I have looked into character encodings in the context of the dplyr >> package, and I have observed the following behavior: >> >> - Strings are treated preferentially in the native encoding >> - Only upon specific request (via translateCharUTF8() or enc2utf8() or >> ...), they are translated to UTF-8 and marked as such >> - On UTF-8 systems, strings are never marked as UTF-8 >> - ASCII strings are marked as ASCII internally, but this information >> doesn't seem to be available, e.g., Encoding() returns &quo...
2010 Feb 22
1
shash in unique.c
...(STRING_ELT(x,indx) == NA_STRING) return 0; return scatter((unsigned int) (STRING_ELT(x,indx), d); } rather than its current form which appears to hash the string it points to : static int shash(SEXP x, int indx, HashData *d) { unsigned int k; const char *p; if(d->useUTF8) p = translateCharUTF8(STRING_ELT(x, indx)); else p = translateChar(STRING_ELT(x, indx)); k = 0; while (*p++) k = 11 * k + *p; /* was 8 but 11 isn't a power of 2 */ return scatter(k, d); } Looking at sequal, below, and reading its comments, if the pointers are equal it doesn't look at...
2010 Jun 19
1
more powerful iconv
...uot;), "to"); if(!isString(CADDDR(args)) || length(CADDDR(args)) != 1) error(_("invalid '%s' argument"), "sub"); - if(STRING_ELT(CADDDR(args), 0) == NA_STRING) sub = NULL; + if(STRING_ELT(CADDDR(args), 0) == NA_STRING || isRawx) sub = NULL; else sub = translateChar(STRING_ELT(CADDDR(args), 0)); mark = asLogical(CAD4R(args)); if(mark == NA_LOGICAL) @@ -584,7 +585,7 @@ PROTECT(ans = duplicate(x)); R_AllocStringBuffer(0, &cbuff); /* 0 -> default */ for(i = 0; i < LENGTH(x); i++) { - si = STRING_ELT(x, i); + si = isRawx ? x : STRING_E...
2013 Jan 11
1
Patch for setwd() to show path in error message
...ameToWchar(STRING_ELT(s, 0), TRUE); if(_wchdir(path) < 0) - error(_("cannot change working directory")); + error(_("cannot change working directory to '%s'"), path); } #else { const char *path = R_ExpandFileName(translateChar(STRING_ELT(s, 0))); if(chdir(path) < 0) - error(_("cannot change working directory")); + error(_("cannot change working directory to '%s'"), path); } #endif return(wd); TRANSLATIONS: I have zero experience with GNU gettext/*.po files, but...
2019 May 26
2
rbind has confusing result for custom sub-class (possible bug?)
...licable method *for what*? Glancing at the source code would suggest it's looking for rbind.IDate: https://github.com/wch/r-source/blob/trunk/src/main/bind.c#L1051-L1063 const char *generic = ((PRIMVAL(op) == 1) ? "cbind" : "rbind"); // should be rbind here const char *s = translateChar(STRING_ELT(classlist, i)); // iterating over the classes, should get to IDate first sprintf(buf, "%s.%s", generic, s); // should be rbind.IDate but adding this method (or even exporting it) is no help [ simply defining rbind.IDate = function(...) as.IDate(NextMethod()) ] Lastly, it appe...
2020 Jun 07
4
[External] Re: use of the tcltk package crashes R 4.0.1 for Windows
...l pointer, followed by setting the pointer to NULL. At that point of tcltk.c, we have >>>> >>>> for (objc = i = 0; i < length(avec); i++){ >>>> const char *s; >>>> char *tmp; >>>> if (!isNull(nm) && strlen(s = translateChar(STRING_ELT(nm, i)))){ >>>> // tmp = calloc(strlen(s)+2, sizeof(char)); >>>> tmp = Calloc(strlen(s)+2, char); >>>> *tmp = '-'; >>>> strcpy(tmp+1, s); >>>> objv[objc++] = Tcl_NewStri...
2019 May 26
2
rbind has confusing result for custom sub-class (possible bug?)
...ld suggest it's looking for rbind.IDate: > > > > https://github.com/wch/r-source/blob/trunk/src/main/bind.c#L1051-L1063 > > > > const char *generic = ((PRIMVAL(op) == 1) ? "cbind" : "rbind"); // should > > be rbind here > > const char *s = translateChar(STRING_ELT(classlist, i)); // iterating over > > the classes, should get to IDate first > > sprintf(buf, "%s.%s", generic, s); // should be rbind.IDate > > > > but adding this method (or even exporting it) is no help [ simply defining > > rbind.IDate = functi...
2017 May 09
2
source(), parse(), and foreign UTF-8 characters
...derstanding of the problem, and I'm grateful for any feedback you might have. I have looked into character encodings in the context of the dplyr package, and I have observed the following behavior: - Strings are treated preferentially in the native encoding - Only upon specific request (via translateCharUTF8() or enc2utf8() or ...), they are translated to UTF-8 and marked as such - On UTF-8 systems, strings are never marked as UTF-8 - ASCII strings are marked as ASCII internally, but this information doesn't seem to be available, e.g., Encoding() returns "unknown" for such strings...
2019 May 27
2
rbind has confusing result for custom sub-class (possible bug?)
...> > > > https://github.com/wch/r-source/blob/trunk/src/main/bind.c#L1051-L1063 > > > > > > > > const char *generic = ((PRIMVAL(op) == 1) ? "cbind" : "rbind"); // > should > > > > be rbind here > > > > const char *s = translateChar(STRING_ELT(classlist, i)); // > iterating over > > > > the classes, should get to IDate first > > > > sprintf(buf, "%s.%s", generic, s); // should be rbind.IDate > > > > > > > > but adding this method (or even exporting it) is no help [ s...
2020 Jun 07
0
[External] Re: use of the tcltk package crashes R 4.0.1 for Windows
...e not freeing a null pointer, followed by setting the pointer to NULL. At that point of tcltk.c, we have >>> >>> for (objc = i = 0; i < length(avec); i++){ >>> const char *s; >>> char *tmp; >>> if (!isNull(nm) && strlen(s = translateChar(STRING_ELT(nm, i)))){ >>> // tmp = calloc(strlen(s)+2, sizeof(char)); >>> tmp = Calloc(strlen(s)+2, char); >>> *tmp = '-'; >>> strcpy(tmp+1, s); >>> objv[objc++] = Tcl_NewStringObj(tmp, -1); >...