Project

General

Profile

Actions

Feature #14574

open

percent literals and binary encoding strings

Added by pb (pumbur _) over 3 years ago. Updated over 3 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:85913]

Description

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:

define_percent_literal(:b){|q| q.force_encoding('binary') }
%b'\x00' #=> "\x00"
Actions

Also available in: Atom PDF