[Blotter-commits] r1040 - pkg/FinancialInstrument/R
G See
gsee000 at gmail.com
Mon Jun 4 02:26:32 CEST 2012
For reference, here is a demo of the problem that seems to be solved
by using `useBytes=TRUE`
> strings <- c("Commodity Index\xae \x96 Agriculture", "something else", "AlphaDEX\xae Fund")
> grep("Commodity", strings)
integer(0)
Warning messages:
1: In grep("Commodity", strings) :
input string 1 is invalid in this locale
2: In grep("Commodity", strings) :
input string 3 is invalid in this locale
> grep("Commodity", strings, useByte=TRUE)
[1] 1
> grep("\xae", strings, fixed=TRUE)
Error in grep("\xae", strings, fixed = TRUE) :
regular expression is invalid in this locale
> grep("\xae", strings, fixed=TRUE, useBytes=TRUE)
[1] 1 3
> grep("\x96", strings, fixed=TRUE)
Error in grep("\x96", strings, fixed = TRUE) :
regular expression is invalid in this locale
> grep("\x96", strings, fixed=TRUE, useBytes=TRUE)
[1] 1
Garrett
On Sun, Jun 3, 2012 at 7:20 PM, <noreply at r-forge.r-project.org> wrote:
> Author: gsee
> Date: 2012-06-04 02:19:59 +0200 (Mon, 04 Jun 2012)
> New Revision: 1040
>
> Modified:
> pkg/FinancialInstrument/R/find.instrument.R
> Log:
> useBytes in grep to avoid warning about invalid input in multibyte locales.
>
> Modified: pkg/FinancialInstrument/R/find.instrument.R
> ===================================================================
> --- pkg/FinancialInstrument/R/find.instrument.R 2012-06-03 23:50:43 UTC (rev 1039)
> +++ pkg/FinancialInstrument/R/find.instrument.R 2012-06-04 00:19:59 UTC (rev 1040)
> @@ -63,5 +63,6 @@
> instrument.table(Symbols, exclude=exclude)
> } else buildHierarchy(Symbols, where[!where %in% exclude])
> unique(tbl[unique(unname(unlist(apply(tbl, 2, function(x)
> - grep(pattern=text, x=x, ignore.case=ignore.case, ...))))), 1])
> + grep(pattern=text, x=x, ignore.case=ignore.case,
> + useBytes=TRUE, ...))))), 1])
> }
>
> _______________________________________________
> Blotter-commits mailing list
> Blotter-commits at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/blotter-commits
More information about the Blotter-commits
mailing list