From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id E529F1F4B8 for ; Fri, 11 Oct 2024 08:06:29 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=CJcz3cLE; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=dQfKlUxe; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1728633957; bh=6nnN+vGnNBtMydA+TP9X1r5A5hUtRI30kZxXy0F/3II=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=CJcz3cLERgpQPktIggfM2OehuV4cHk1JcVe9YFsjSlFGxUaYKomklY+6aoTdLid6n cXL5XjwYD1PJvciDp9kxYgT0zerWQQOo855zGl0AjRs+xwr3M16j5p8OwDcwMgTIm+ KSXNDDyI9N7JO5UcC9nfIiT8NIgX4zMgNjmipr38= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 7C21143FF7 for ; Fri, 11 Oct 2024 08:05:57 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=dQfKlUxe; dkim-atps=neutral Received: from s.wfbtzhsv.outbound-mail.sendgrid.net (s.wfbtzhsv.outbound-mail.sendgrid.net [159.183.224.104]) by nue.mailmanlists.eu (Postfix) with ESMTPS id D986943E8C for ; Fri, 11 Oct 2024 08:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=hwyHHGnkf+eesIj8MbtP9kxOTZabBabKtDUQ+w6WA/c=; b=dQfKlUxe+/pgJXzxAfur8+pGinSoWXFSv6ojpu5TjGO0aJJU8yZIHqfYI1yaNmuRaQou 8hrS5rcHyS/fXgsjdn81IKCykg8MMtu+1z4WFypKH8Eo1NORcXjFh6ixrSnOg/UNWYF+T5 XCmDsYfbdCyqxrxImheOLty54IRrdJkzJgzu7cC4lxd5QJnpceYcLbtWT6ifIa0yc3JomW 5QRo5UzbwrtdM/BASlS6NVDYHwOzeFvQDLLBYTlSMgS2BxBmokN2XMSFVhpgxil1OCKcU+ gcUbIOruMyMz69kfu5QVhAGRsFbm1z2Teg7ct5NSrPbiID74DDjqunpLjmE9dApA== Received: by recvd-5577bcb48c-nrjxl with SMTP id recvd-5577bcb48c-nrjxl-1-6708DC58-19 2024-10-11 08:05:44.974838664 +0000 UTC m=+2470048.658929546 Received: from herokuapp.com (unknown) by geopod-ismtpd-canary-0 (SG) with ESMTP id kqsmsxcQTjuzU5b3TSM2ng for ; Fri, 11 Oct 2024 08:05:44.867 +0000 (UTC) Date: Fri, 11 Oct 2024 08:05:45 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 20792 X-Redmine-Issue-Author: kddnewton X-Redmine-Issue-Priority: Normal X-Redmine-Sender: nobu X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 96144 X-SG-EID: =?us-ascii?Q?u001=2E5PtzXJ23KrYzgM1nrOIr+EQ222PyrDaWSg0Er8CZ8tP86xyXmBM81zBKD?= =?us-ascii?Q?HreavdFYMbHjxXOR6UPMkt=2Fu9CyBIp6y52n8D2y?= =?us-ascii?Q?qA9zqurrgUd3Gz0efuD34=2FIEs8PGH+bB5kDRRcP?= =?us-ascii?Q?Vl1R3R8ktsJ6tZfyeoc7ynWU3Wcc4VK7Tfu+kph?= =?us-ascii?Q?nI5QLCdSSo84TQimRuIodiOR8SkzqgULM6x50r1?= =?us-ascii?Q?DF129=2FDkQZST2pg9akpLpvR0aqex5fD1ERcQXZR?= =?us-ascii?Q?=2FtcWxNo1t=2FbZFj6myYdNTr97MA=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: XHBR2VRQ2SLGTZ5LESFRQTRI3EQTISV5 X-Message-ID-Hash: XHBR2VRQ2SLGTZ5LESFRQTRI3EQTISV5 X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:119509] [Ruby master Feature#20792] String#forcible_encoding? List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "nobu (Nobuyoshi Nakada) via ruby-core" Cc: "nobu (Nobuyoshi Nakada)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20792 has been updated by nobu (Nobuyoshi Nakada). nirvdrum (Kevin Menard) wrote in #note-6: > I'm partial to this one. Alternatively, it could be nice to have the inverse: `Encoding#valid_string?` (or `Encoding#valid_bytes?`). I prefer `valid_sequence?` over `valid_bytes?`. > I like the symmetry, but you'd give up the short-hand of specifying the encoding by its string name. `Encoding.valid_string?(str, enc)` may be possible as a short-hand for `Encoding.find(enc).valid_string?(str)`. ---------------------------------------- Feature #20792: String#forcible_encoding? https://bugs.ruby-lang.org/issues/20792#change-110124 * Author: kddnewton (Kevin Newton) * Status: Open ---------------------------------------- I would like to add a method to String called `forcible_encoding?(encoding)`. This would return true or false depending on whether the receiver can be forced into the given encoding without breaking the string. It would effectively be an alias for: ```ruby def forcible_encoding?(enc) original = encoding result = force_encoding(enc).valid_encoding? force_encoding(original) result end ``` I would like this method because there are extremely rare but possible circumstances where source files are marked as binary but contain UTF-8-encoded characters. In that case I would like to check if it's possible to cleanly force UTF-8 before actually doing it. The code I'm trying to replace is here: https://github.com/ruby/prism/blob/d6e9b8de36b4d18debfe36e4545116539964ceeb/lib/prism/parse_result.rb#L15-L30. The pull request for the code is here: https://github.com/ruby/ruby/pull/11851. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/