[#83773] [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769 — usa@...
Issue #14108 has been updated by usa (Usaku NAKAMURA).
9 messages
2017/11/15
[#83774] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— Eric Wong <normalperson@...>
2017/11/15
usa@garbagecollect.jp wrote:
[#83775] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— "U.NAKAMURA" <usa@...>
2017/11/15
Hi, Eric
[#83779] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— Eric Wong <normalperson@...>
2017/11/15
"U.NAKAMURA" <usa@garbagecollect.jp> wrote:
[#83781] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— "U.NAKAMURA" <usa@...>
2017/11/15
Hi, Eric,
[#83782] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— Eric Wong <normalperson@...>
2017/11/15
"U.NAKAMURA" <usa@garbagecollect.jp> wrote:
[ruby-core:83880] [Ruby trunk Feature#12275] String unescape
From:
tad.a.digger@...
Date:
2017-11-25 08:20:40 UTC
List:
ruby-core #83880
Issue #12275 has been updated by tad (Tadashi Saito).
> Still, there is the question of what the encoding of the result of #unescape should be.
Indeed. It is one of few things that I'm still worried about.
For now, `undump` inherits receiver's encoding:
~~~ ruby
"abc".encode('euc-jp').undump.encoding #=> #<Encoding:EUC-JP>
~~~
But it may cause some inconvenient errors like:
~~~ ruby
utf8 = "\xE3\x81\x82".force_encoding('utf-8')
dumped = utf8.dump.encode('ascii') # we can treat dumped string as ASCII
dumped.valid_encoding? #=> always true, of course
dumped.undump #=> RangeError: 12354 out of char range
~~~
`dump`-ed string may contain any codepoints without original encoding information basically,
and this situation reminds me about `Integer#chr(encoding)`.
Then `undump` may needs an argument too, to specify encoding of result string, I think.
(Of course `dumped.force_encoding('utf-8')` before `undump` solves this problem, but I feel it's little redundant.)
Any thoughts about this?
Although this is another topic, I think that the name of this new method is confirmed as
`#undump` (not `#unescape`) by @matz. Please see https://bugs.ruby-lang.org/issues/12275#note-6
and below. (I believe it's a good name because it reminds its spec clearly.)
----------------------------------------
Feature #12275: String unescape
https://bugs.ruby-lang.org/issues/12275#change-67919
* Author: asnow (Andrew Bolshov)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
I think it will be usefull to have function that convert input string as it was written in prime qouted string or in double qouted string. It's part of metaprogramming.
Example:
~~~ ruby
class String
# Create new string like it will be writed in qoutes. Optional argument define type of qouting used: true - prime qoute, false - double qoute. Default is double qoute.
def unescape prime = false
eval( prime ? "'#{self}'" : "\"#{self}\"" )
end
end
"\\\t".unescape # => "\t"
~~~
Other requests:
http://www.rubydoc.info/github/ronin-ruby/ronin-support/String:unescape
http://stackoverflow.com/questions/4265928/how-do-i-unescape-c-style-escape-sequences-from-ruby
http://stackoverflow.com/questions/8639642/best-way-to-escape-and-unescape-strings-in-ruby
Realized
http://www.rubydoc.info/github/ronin-ruby/ronin-support/String:unescape
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>