Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #35897
| Path | csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: java.net.URLEncoder.encode + UTF-8 (rant) |
| Date | Mon, 14 Nov 2016 14:45:21 -0500 |
| Organization | A noiseless patient Spider |
| Lines | 32 |
| Message-ID | <o0d47k$5p0$1@dont-email.me> (permalink) |
| References | <slrno09hi9.456.avl@login.logic.tuwien.ac.at> <o0d1tp$sft$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Mon, 14 Nov 2016 19:44:52 -0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="3d97c2e4008566727f15963f51d702f2"; logging-data="5920"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zC6b4VFBsHI33l+MbccCi" |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 |
| In-Reply-To | <o0d1tp$sft$1@dont-email.me> |
| Cancel-Lock | sha1:Cddh6G4enrRQPqKNA44cxahnurM= |
| Xref | csiph.com comp.lang.java.programmer:35897 |
Show key headers only | View raw
On 11/14/2016 2:05 PM, Daniele Futtorovic wrote:
> On 2016-10-17 14:38, Andreas Leitgeb wrote:
>> <rant target="java.net.URLEncoder.encode(String s, String enc)">
>>
>> This method should (according to the w3c) only be used with UTF-8
>> and UTF-8 is always supposed to be supported by Java.
>>
>> Why is there no java.net.URLEncoder.encodeUTF8(String s) that
>> would free me from that boring
>> try {...} catch (UnsupportedEncodingException ign) {...}
>> boilerplate? (What code do good(tm) Java programmers even put
>> into this catch clause, that is expected to never run, anyway?)
>
> throw new AssertionError( ing.toString() );
In situations like this, I think
throw new AssertionError("BUG!", ign);
is marginally better in that it preserves all the information from
the "cannot happen" exception instead of only its message text. (If
you ever catch a "cannot happen" exception something very odd must
have happened, and if something *that* odd happens you'll be glad of
every possible clue ...)
> But yeah, it's annoying.
Yes. Sometimes, anyhow.
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
java.net.URLEncoder.encode + UTF-8 (rant) Andreas Leitgeb <avl@logic.at> - 2016-10-17 12:38 +0000
Re: java.net.URLEncoder.encode + UTF-8 (rant) j4n bur53 <janburse@fastmail.fm> - 2016-10-17 16:55 +0200
Re: java.net.URLEncoder.encode + UTF-8 (rant) Arne Vajhøj <arne@vajhoej.dk> - 2016-10-19 21:35 -0400
Re: java.net.URLEncoder.encode + UTF-8 (rant) Daniele Futtorovic <da.futt.news@laposte.net> - 2016-11-14 20:05 +0100
Re: java.net.URLEncoder.encode + UTF-8 (rant) Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-11-14 14:45 -0500
csiph-web