[#393012] Basic Ruby performance — Dmitry Nikiforov <dniq@...>

Hello all!

43 messages 2012/02/02
[#393013] Re: Basic Ruby performance — Dmitry Nikiforov <dniq@...> 2012/02/02

Here's another example with significantly bigger performance difference:

[#393015] Re: Basic Ruby performance — Ryan Davis <ryand-ruby@...> 2012/02/02

[#393016] Re: Basic Ruby performance — Peter Vandenabeele <peter@...> 2012/02/02

On Fri, Feb 3, 2012 at 12:20 AM, Ryan Davis <ryand-ruby@zenspider.com>wrote:

[#393020] Re: Basic Ruby performance — Ryan Davis <ryand-ruby@...> 2012/02/03

[#393076] Problem migrating to Ruby 1.9.2 — Patrick Bayford <pbayford@...>

Some assistance please - I have a Ruby project, which I started in Ruby

10 messages 2012/02/03

[#393164] Using _ like in Scala? — Marc Heiler <shevegen@...>

fruits = %w( apple banana orange )

27 messages 2012/02/06
[#393201] Re: Using _ like in Scala? — Tony Arcieri <tony.arcieri@...> 2012/02/07

On Mon, Feb 6, 2012 at 10:54 AM, Marc Heiler <shevegen@linuxmail.org> wrote:

[#393204] Re: Using _ like in Scala? — Eric Christopherson <echristopherson@...> 2012/02/07

On Mon, Feb 6, 2012 at 7:21 PM, Tony Arcieri <tony.arcieri@gmail.com> wrote:

[#393206] Re: Using _ like in Scala? — Tony Arcieri <tony.arcieri@...> 2012/02/07

On Mon, Feb 6, 2012 at 5:56 PM, Eric Christopherson <

[#393208] Re: Using _ like in Scala? — Kevin <darkintent@...> 2012/02/07

On Mon, Feb 6, 2012 at 9:07 PM, Tony Arcieri <tony.arcieri@gmail.com> wrote:

[#393216] Re: Using _ like in Scala? — Robert Klemme <shortcutter@...> 2012/02/07

On Tue, Feb 7, 2012 at 6:56 AM, Kevin <darkintent@gmail.com> wrote:

[#393219] Re: Using _ like in Scala? — Josh Cheek <josh.cheek@...> 2012/02/07

On Tue, Feb 7, 2012 at 4:47 AM, Robert Klemme <shortcutter@googlemail.com>wrote:

[#393220] Re: Using _ like in Scala? — Robert Klemme <shortcutter@...> 2012/02/07

On Tue, Feb 7, 2012 at 1:00 PM, Josh Cheek <josh.cheek@gmail.com> wrote:

[#393240] Re: Using _ like in Scala? — Josh Cheek <josh.cheek@...> 2012/02/08

On Tue, Feb 7, 2012 at 9:15 AM, Robert Klemme <shortcutter@googlemail.com>wrote:

[#393254] Re: Using _ like in Scala? — Robert Klemme <shortcutter@...> 2012/02/08

On Wed, Feb 8, 2012 at 3:43 AM, Josh Cheek <josh.cheek@gmail.com> wrote:

[#393259] Re: Using _ like in Scala? — Josh Cheek <josh.cheek@...> 2012/02/08

On Wed, Feb 8, 2012 at 5:58 AM, Robert Klemme <shortcutter@googlemail.com>wrote:

[#393181] Tork 18.0.0 — "Suraj N. Kurapati" <sunaku@...>

Tork - Test with fork - https://github.com/sunaku/tork#readme

16 messages 2012/02/06
[#393183] Re: [ANN] Tork 18.0.0 — Bartosz Dziewoński <matma.rex@...> 2012/02/06

You have faster major version release cycle than Chrome...

[#393189] Re: [ANN] Tork 18.0.0 — Quintus <sutniuq@...> 2012/02/06

Am 06.02.2012 22:07, schrieb Bartosz Dziewoナгki:

[#393203] Re: Tork 18.0.0 — Suraj Kurapati <sunaku@...> 2012/02/07

Marvin G=C3=BClker wrote in post #1044440:

[#393347] Symbol garbage collection — Dido Sevilla <dido.sevilla@...>

I've always wondered why Ruby didn't do garbage collection of symbols,

13 messages 2012/02/10

[#393402] Who Administrates this list and how can the community help save this list from the noise. — andrew mcelroy <sophrinix@...>

It is very clear that this list has been under a incredibly heavy

21 messages 2012/02/11
[#393403] Re: Who Administrates this list and how can the community help save this list from the noise. — serialhex <serialhex@...> 2012/02/11

+1

[#393407] Re: Who Administrates this list and how can the community help save this list from the noise. — Cathy Alomari <cathy1428@...> 2012/02/11

Good luck, I doubt anyone is paying attention. I have seen numerous

[#393410] Re: Who Administrates this list and how can the community help save this list from the noise. — "Darryl L. Pierce" <mcpierce@...> 2012/02/11

On Sat, Feb 11, 2012 at 1:12 PM, Cathy Alomari <cathy1428@gmail.com> wrote:

[#393430] Re: Who Administrates this list and how can the community help save this list from the noise. — Cathy Alomari <cathy1428@...> 2012/02/13

On Sat, Feb 11, 2012 at 10:48 AM, Darryl L. Pierce <mcpierce@gmail.com>wrote:

[#393432] Re: Who Administrates this list and how can the community help save this list from the noise. — Bartosz Dziewoński <matma.rex@...> 2012/02/13

2012/2/13 Cathy Alomari <cathy1428@gmail.com>:

[#393434] Re: Who Administrates this list and how can the community help save this list from the noise. — Rimantas Liubertas <rimantas@...> 2012/02/13

> Have you tried mailing ruby-talk-ctl@ruby-lang.org (mailto:ruby-talk-ctl@ruby-lang.org) with "unsubscribe"

[#393412] the ruby syntax — maven apache <apachemaven0@...>

Hi:

19 messages 2012/02/12
[#393413] Re: the ruby syntax — Bartosz Dziewoński <matma.rex@...> 2012/02/12

When a hash is the last argument to a method, you can skip its open-

[#393416] Re: the ruby syntax — maven apache <apachemaven0@...> 2012/02/12

2012/2/12 Bartosz Dziewo=C5=84ski <matma.rex@gmail.com>

[#393435] Re: the ruby syntax — Saji Hameed <saji@...> 2012/02/13

On Sun, Feb 12, 2012 at 10:49 PM, maven apache <apachemaven0@gmail.com> wro=

[#393546] Difference between 1.9.2 and 1.9.3 — James French <James.French@...>

module A <- line 1

12 messages 2012/02/20
[#393558] Re: Difference between 1.9.2 and 1.9.3 — Dave Aronson <rubytalk2dave@...> 2012/02/21

On Mon, Feb 20, 2012 at 12:25, James French

[#393548] Accessing a local variable through a symbol — Ralph Shnelvar <ralphs@...32.com>

Let's say I have

11 messages 2012/02/20

[#393671] Rubymoticons — Dave Aronson <rubytalk2dave@...>

I was demonstrating injection of a symbol, and noticed a familiar

12 messages 2012/02/28

str.encode! sets valid_encoding even if resulting string is invalid (1.9.3)

From: Tim Garnett <tgarnett@...>
Date: 2012-02-05 14:15:31 UTC
List: ruby-talk #393123
I get some untrusted input from some of our partners that should be in
utf-8 (or generally plain 7-bit ascii), but isn't always (and in fact in
some cases appears to be a multiple incompatible string encodings
concatenated together, truncated strangely then joined, or perhaps just
noise).  I'd like to convert the string into something that's valid
utf-8 so I can work with it, ideally keeping as much of the valid
encoding parts of the string as possible.  I tried encode! but ran into
weirdness where it would return a string that claims to valid but isn't
(which seems like a bug).

# test strings
1.9.3p0> str1 =3D "ceramic
rollers1\x82=D1=80=D1=8B/=D0=A0=D0=B5=D0=B9=D0=B4-=D0=B1=D0=BE=D1=81=D1=81=
=D1=8B/50=E2=80=9459F\xAA\xB3\xF3\xC7\xF9)-\xB0\xA1\xB3\xAA\xB4=D9=BC\xF8=
.xls&tempFileName=3D1310611982277\xC1\xA6110=C8=B8
\xC7=D5=B0\xDD\xC0=DA=B8\xED\xB4\xDC(\xC1\xF6\xBF\xAA\xB3\xF3\xC7\xF9)-\x=
B0\xA1\xB3\xAA\xB4=D9=BC\xF8.xls"
1.9.3p0> str2 =3D "hydroxide+caustic =E7=94=B0=E7=94=B1\xE7\xBE"

# encode!
1.9.3p0> a =3D str1.dup
1.9.3p0> a.valid_encoding?
 =3D> false
1.9.3p0> a.encode!(Encoding::UTF_8, Encoding::UTF_8, :invalid=3D>:replace=
,
:undef=3D>:replace, :replace=3D>'')
 =3D> "ceramic
rollers1\x82=D1=80=D1=8B/=D0=A0=D0=B5=D0=B9=D0=B4-=D0=B1=D0=BE=D1=81=D1=81=
=D1=8B/50=E2=80=9459F\xAA\xB3\xF3\xC7\xF9)-\xB0\xA1\xB3\xAA\xB4=D9=BC\xF8=
.xls&tempFileName=3D1310611982277\xC1\xA6110=C8=B8
\xC7=D5=B0\xDD\xC0=DA=B8\xED\xB4\xDC(\xC1\xF6\xBF\xAA\xB3\xF3\xC7\xF9)-\x=
B0\xA1\xB3\xAA\xB4=D9=BC\xF8.xls"
1.9.3p0> a.valid_encoding?
 =3D> true
# so far so good
1.9.3p0> a.squeeze(' ')
ArgumentError: invalid byte sequence in UTF-8
  from (irb):10:in `squeeze'
  from (irb):10
  from /home/tgarnett/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
# !!! ruby just claimed the encoding was valid! BUG??
# a.dup.squeeze(' '), "#{a} ".squeeze(' ') both fail as well


Also tried iconv with //IGNORE but it returns
invalid strings on some inputs, and also crashes on some others.  I've
had better luck with unpack/pack, but I was wondering if anyone new a
better way to do this.

# iconv
1.9.3p0> require 'iconv'
1.9.3p0> a =3D str1.dup
1.9.3p0> a =3D Iconv.new('UTF-8//IGNORE', 'UTF-8').iconv(a)
 =3D> "ceramic
rollers1=D1=80=D1=8B/=D0=A0=D0=B5=D0=B9=D0=B4-=D0=B1=D0=BE=D1=81=D1=81=D1=
=8B/50=E2=80=9459F)-=D9=BC.xls&tempFileName=3D1310611982277110=C8=B8
=D5=B0=DA=B8(\xF6\xBF\xAA\xB3)-=D9=BC.xls"
1.9.3p0> a.valid_encoding?
 =3D> false
# no luck here either...
1.9.3p0> b =3D str2.dup
1.9.3p0> b =3D Iconv.new('UTF-8//IGNORE', 'UTF-8').iconv(b)
Iconv::InvalidCharacter: "\xE7\xBE"
  from (irb):22:in `iconv'
  from (irb):22
  from /home/tgarnett/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
# ok, can crash too...


# unpack, pack
1.9.3p0> a =3D str2.dup
1.9.3p0> a =3D a.unpack('C*').pack('U*')
 =3D> "hydroxide+caustic =C3=A7\u0094=C2=B0=C3=A7\u0094=C2=B1=C3=A7=C2=BE=
"
1.9.3p0> a.valid_encoding?
 =3D> true
1.9.3p0> a.squeeze(' ')
 =3D> "hydroxide+caustic =C3=A7\u0094=C2=B0=C3=A7\u0094=C2=B1=C3=A7=C2=BE=
"
# some success, also works for str1

-- =

Posted via http://www.ruby-forum.com/.=

In This Thread

Prev Next