* [ruby-core:85913] [Ruby trunk Feature#14574] percent literals and binary encoding strings
[not found] <redmine.issue-14574.20180304020557@ruby-lang.org>
@ 2018-03-04 2:05 ` pumburu
2018-03-04 3:22 ` [ruby-core:85914] " matthew
` (3 subsequent siblings)
4 siblings, 0 replies; 5+ messages in thread
From: pumburu @ 2018-03-04 2:05 UTC (permalink / raw
To: ruby-core
Issue #14574 has been reported by pb (pumbur _).
----------------------------------------
Feature #14574: percent literals and binary encoding strings
https://bugs.ruby-lang.org/issues/14574
* Author: pb (pumbur _)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
coding `"\x00".force_encoding('binary')` or `["\x00"].pack('a*')` is a hassle, is there a chance to have special percent literal for it?
i.e: `%b"\x00"` would return binary string. (note, signle-character \x00 there is accidental, the idea is force any string from script encoding to binary)
or, more general suggestion:
allow percent literal with any [a-z] character, move all logic to user-level and allow it to be redefinable:
~~~ ruby
define_percent_literal(:b){|q| q.force_encoding('binary') }
%b'\x00' #=> "\x00"
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:85914] [Ruby trunk Feature#14574] percent literals and binary encoding strings
[not found] <redmine.issue-14574.20180304020557@ruby-lang.org>
2018-03-04 2:05 ` [ruby-core:85913] [Ruby trunk Feature#14574] percent literals and binary encoding strings pumburu
@ 2018-03-04 3:22 ` matthew
2018-03-04 3:57 ` [ruby-core:85915] " pumburu
` (2 subsequent siblings)
4 siblings, 0 replies; 5+ messages in thread
From: matthew @ 2018-03-04 3:22 UTC (permalink / raw
To: ruby-core
Issue #14574 has been updated by phluid61 (Matthew Kerwin).
~~~ruby
str = "\x00".b #=> "\x00"
str.encoding #=> #<Encoding:ASCII-8BIT>
~~~
Incidentally, if you care about it:
~~~ruby
str = -"...".b
str.frozen? #=> true
str.encoding #=> #<Encoding:ASCII-8BIT>
~~~
----------------------------------------
Feature #14574: percent literals and binary encoding strings
https://bugs.ruby-lang.org/issues/14574#change-70770
* Author: pb (pumbur _)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
coding `"\x00".force_encoding('binary')` or `["\x00"].pack('a*')` is a hassle, is there a chance to have special percent literal for it?
i.e: `%b"\x00"` would return binary string. (note, signle-character \x00 there is accidental, the idea is force any string from script encoding to binary)
or, more general suggestion:
allow percent literal with any [a-z] character, move all logic to user-level and allow it to be redefinable:
~~~ ruby
define_percent_literal(:b){|q| q.force_encoding('binary') }
%b'\x00' #=> "\x00"
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:85915] [Ruby trunk Feature#14574] percent literals and binary encoding strings
[not found] <redmine.issue-14574.20180304020557@ruby-lang.org>
2018-03-04 2:05 ` [ruby-core:85913] [Ruby trunk Feature#14574] percent literals and binary encoding strings pumburu
2018-03-04 3:22 ` [ruby-core:85914] " matthew
@ 2018-03-04 3:57 ` pumburu
2018-03-04 4:49 ` [ruby-core:85916] " matthew
2018-03-04 7:38 ` [ruby-core:85917] " nobu
4 siblings, 0 replies; 5+ messages in thread
From: pumburu @ 2018-03-04 3:57 UTC (permalink / raw
To: ruby-core
Issue #14574 has been updated by pb (pumbur _).
oops. well, that certainly closes first part for me, the one that agitated me to write issue.
there still was cases where i wanted to define other string literals, but i'm not sure its worth it.
sorry for bothering, if no one has thoughts on second part, issue may be closed.
----------------------------------------
Feature #14574: percent literals and binary encoding strings
https://bugs.ruby-lang.org/issues/14574#change-70771
* Author: pb (pumbur _)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
coding `"\x00".force_encoding('binary')` or `["\x00"].pack('a*')` is a hassle, is there a chance to have special percent literal for it?
i.e: `%b"\x00"` would return binary string. (note, signle-character \x00 there is accidental, the idea is force any string from script encoding to binary)
or, more general suggestion:
allow percent literal with any [a-z] character, move all logic to user-level and allow it to be redefinable:
~~~ ruby
define_percent_literal(:b){|q| q.force_encoding('binary') }
%b'\x00' #=> "\x00"
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:85916] [Ruby trunk Feature#14574] percent literals and binary encoding strings
[not found] <redmine.issue-14574.20180304020557@ruby-lang.org>
` (2 preceding siblings ...)
2018-03-04 3:57 ` [ruby-core:85915] " pumburu
@ 2018-03-04 4:49 ` matthew
2018-03-04 7:38 ` [ruby-core:85917] " nobu
4 siblings, 0 replies; 5+ messages in thread
From: matthew @ 2018-03-04 4:49 UTC (permalink / raw
To: ruby-core
Issue #14574 has been updated by phluid61 (Matthew Kerwin).
I think runtime-customisable percent-literal strings are a bit of a hard ask, since things like %w, %r, %x are so tightly integrated with the parser itself.
Even the question of when to stop consuming (nested brackets? escape characters?) means there will be messy and confusing edge-cases.
I'm not against the idea *per se*, I just think it's not workable in the Ruby we have today.
----------------------------------------
Feature #14574: percent literals and binary encoding strings
https://bugs.ruby-lang.org/issues/14574#change-70772
* Author: pb (pumbur _)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
coding `"\x00".force_encoding('binary')` or `["\x00"].pack('a*')` is a hassle, is there a chance to have special percent literal for it?
i.e: `%b"\x00"` would return binary string. (note, signle-character \x00 there is accidental, the idea is force any string from script encoding to binary)
or, more general suggestion:
allow percent literal with any [a-z] character, move all logic to user-level and allow it to be redefinable:
~~~ ruby
define_percent_literal(:b){|q| q.force_encoding('binary') }
%b'\x00' #=> "\x00"
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:85917] [Ruby trunk Feature#14574] percent literals and binary encoding strings
[not found] <redmine.issue-14574.20180304020557@ruby-lang.org>
` (3 preceding siblings ...)
2018-03-04 4:49 ` [ruby-core:85916] " matthew
@ 2018-03-04 7:38 ` nobu
4 siblings, 0 replies; 5+ messages in thread
From: nobu @ 2018-03-04 7:38 UTC (permalink / raw
To: ruby-core
Issue #14574 has been updated by nobu (Nobuyoshi Nakada).
"Customizable percent literal" had been proposed as `%y`, YAML literal.
----------------------------------------
Feature #14574: percent literals and binary encoding strings
https://bugs.ruby-lang.org/issues/14574#change-70773
* Author: pb (pumbur _)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
coding `"\x00".force_encoding('binary')` or `["\x00"].pack('a*')` is a hassle, is there a chance to have special percent literal for it?
i.e: `%b"\x00"` would return binary string. (note, signle-character \x00 there is accidental, the idea is force any string from script encoding to binary)
or, more general suggestion:
allow percent literal with any [a-z] character, move all logic to user-level and allow it to be redefinable:
~~~ ruby
define_percent_literal(:b){|q| q.force_encoding('binary') }
%b'\x00' #=> "\x00"
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-03-04 7:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <redmine.issue-14574.20180304020557@ruby-lang.org>
2018-03-04 2:05 ` [ruby-core:85913] [Ruby trunk Feature#14574] percent literals and binary encoding strings pumburu
2018-03-04 3:22 ` [ruby-core:85914] " matthew
2018-03-04 3:57 ` [ruby-core:85915] " pumburu
2018-03-04 4:49 ` [ruby-core:85916] " matthew
2018-03-04 7:38 ` [ruby-core:85917] " nobu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).