Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

An engineer is someone who does list processing in FORTRAN.


devel / comp.lang.java.programmer / Convert fom \uXXXX to %XX%XX

SubjectAuthor
* Convert fom \uXXXX to %XX%XXservoloro
+* Re: Convert fom \uXXXX to %XX%XXservoloro
|`- Re: Convert fom \uXXXX to %XX%XXArne Vajhøj
`* Re: Convert fom \uXXXX to %XX%XXe.d.pro...@gmail.com
 `- Re: Convert fom \uXXXX to %XX%XXservoloro

1
Convert fom \uXXXX to %XX%XX

<trvq66$4aaj$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9987&group=comp.lang.java.programmer#9987

  copy link   Newsgroups: comp.lang.java.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: cb...@ppp.it (servoloro)
Newsgroups: comp.lang.java.programmer
Subject: Convert fom \uXXXX to %XX%XX
Date: Wed, 8 Feb 2023 10:31:50 +0100
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <trvq66$4aaj$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 8 Feb 2023 09:31:50 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="d3dcdc239aaa8b564ef38b269421977a";
logging-data="141651"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ADxZG373y3UgD1HFTT9r8B/verSgBGqg="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Cancel-Lock: sha1:1phzFRPpVYDWbahOx9FjoveY1V0=
Content-Language: it-IT
 by: servoloro - Wed, 8 Feb 2023 09:31 UTC

*Newbie question*
I have to convert a string from the format (how it's called ?)
\uXXXX
to (again:how it's called ?)
%XX%XX
i.e. from \u00dc to %C3%9C.
Apart from doing a dumb replaceAll
s=s.replaceAll("\u00dc", "%C3%9C");
I'm sure there is a smarter way.
Not knowing the names of the formats Google didn't help me :-(
Could someone give me hints/directions ?
TIA

Re: Convert fom \uXXXX to %XX%XX

<trvq8l$4aaj$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9988&group=comp.lang.java.programmer#9988

  copy link   Newsgroups: comp.lang.java.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: cb...@ppp.it (servoloro)
Newsgroups: comp.lang.java.programmer
Subject: Re: Convert fom \uXXXX to %XX%XX
Date: Wed, 8 Feb 2023 10:33:09 +0100
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <trvq8l$4aaj$2@dont-email.me>
References: <trvq66$4aaj$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 8 Feb 2023 09:33:09 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="d3dcdc239aaa8b564ef38b269421977a";
logging-data="141651"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18T2gdgNEK8SJHvhxDJLGjAMcMy90MhcrU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Cancel-Lock: sha1:zl9Rg8EgT+W2NtVXckKK5yqUrwM=
Content-Language: it-IT
In-Reply-To: <trvq66$4aaj$1@dont-email.me>
 by: servoloro - Wed, 8 Feb 2023 09:33 UTC

Sorry it is:
> s=s.replaceAll("\\\\u00dc", "%C3%9C");

On 2/8/23 10:31, servoloro wrote:
> *Newbie question*
> I have to convert a string from the format (how it's called ?)
> \uXXXX
> to (again:how it's called ?)
> %XX%XX
> i.e. from \u00dc to %C3%9C.
> Apart from doing a dumb replaceAll
> I'm sure there is a smarter way.
> Not knowing the names of the formats Google didn't help me :-(
> Could someone give me hints/directions ?
> TIA

Re: Convert fom \uXXXX to %XX%XX

<e3f232ad-2503-480b-868e-f20bc08e6e57n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9989&group=comp.lang.java.programmer#9989

  copy link   Newsgroups: comp.lang.java.programmer
X-Received: by 2002:a0c:cb92:0:b0:56c:1ac0:37d6 with SMTP id p18-20020a0ccb92000000b0056c1ac037d6mr504895qvk.63.1675859317448;
Wed, 08 Feb 2023 04:28:37 -0800 (PST)
X-Received: by 2002:a37:b907:0:b0:71f:2c96:6783 with SMTP id
j7-20020a37b907000000b0071f2c966783mr661946qkf.294.1675859317209; Wed, 08 Feb
2023 04:28:37 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.java.programmer
Date: Wed, 8 Feb 2023 04:28:36 -0800 (PST)
In-Reply-To: <trvq66$4aaj$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=98.237.40.232; posting-account=2czF5goAAAD4GBMPIGV4KcD2K4PhoB_H
NNTP-Posting-Host: 98.237.40.232
References: <trvq66$4aaj$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e3f232ad-2503-480b-868e-f20bc08e6e57n@googlegroups.com>
Subject: Re: Convert fom \uXXXX to %XX%XX
From: e.d.prog...@gmail.com (e.d.pro...@gmail.com)
Injection-Date: Wed, 08 Feb 2023 12:28:37 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2424
 by: e.d.pro...@gmail.com - Wed, 8 Feb 2023 12:28 UTC

> *Newbie question*
> I have to convert a string from the format (how it's called ?)
> \uXXXX
> to (again:how it's called ?)
> %XX%XX
> i.e. from \u00dc to %C3%9C.
> Apart from doing a dumb replaceAll
> s=s.replaceAll("\u00dc", "%C3%9C");
> I'm sure there is a smarter way.
> Not knowing the names of the formats Google didn't help me :-(
> Could someone give me hints/directions ?
> TIA
If you google "\u00dc" you'll see it's called unicode, expressed as a Java String, that code specifically being "latin capitol letter U with diaersis"..
Note if you want to replace all occurrences of a single string within a string, call the .replace method. Use .replaceAll if you need the replacement value to be a regex.
If you google "%C3%9C" you'll see it's also unicode, expressed in url encoding.
If you google "java unicode url encode" you'll see some different ways to do that, depending on your use case. Is it for a domain name? query string parameter? web page label value? is there a framework? more context is required to get specific on the solution.
If you know that's the only character you'll need to convert, the replace method could suffice, otherwise you'll likely want to call an API encode method.

Re: Convert fom \uXXXX to %XX%XX

<ts09gd$6sp3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9990&group=comp.lang.java.programmer#9990

  copy link   Newsgroups: comp.lang.java.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: cb...@ppp.it (servoloro)
Newsgroups: comp.lang.java.programmer
Subject: Re: Convert fom \uXXXX to %XX%XX
Date: Wed, 8 Feb 2023 14:53:16 +0100
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <ts09gd$6sp3$1@dont-email.me>
References: <trvq66$4aaj$1@dont-email.me>
<e3f232ad-2503-480b-868e-f20bc08e6e57n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 8 Feb 2023 13:53:17 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="d3dcdc239aaa8b564ef38b269421977a";
logging-data="226083"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Cl6jxF8BOikkC3v/GsX3qKvwY5grjo7M="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Cancel-Lock: sha1:/TGvrdxmVMxmyktDHSclG1i2V8M=
Content-Language: it-IT
In-Reply-To: <e3f232ad-2503-480b-868e-f20bc08e6e57n@googlegroups.com>
 by: servoloro - Wed, 8 Feb 2023 13:53 UTC

On 2/8/23 13:28, e.d.pro...@gmail.com wrote:
> If you google "\u00dc" you'll see it's called unicode, expressed as a Java String, that code specifically being "latin capitol letter U with diaersis".
> ...
THANKS !

Re: Convert fom \uXXXX to %XX%XX

<ts0eqa$7k9c$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9992&group=comp.lang.java.programmer#9992

  copy link   Newsgroups: comp.lang.java.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: arn...@vajhoej.dk (Arne Vajhøj)
Newsgroups: comp.lang.java.programmer
Subject: Re: Convert fom \uXXXX to %XX%XX
Date: Wed, 8 Feb 2023 10:23:50 -0500
Organization: A noiseless patient Spider
Lines: 111
Message-ID: <ts0eqa$7k9c$1@dont-email.me>
References: <trvq66$4aaj$1@dont-email.me> <trvq8l$4aaj$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 8 Feb 2023 15:23:54 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="63732f2b663c4b5767e02c5e507319d5";
logging-data="250156"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Fz6QPp+lHhManyu58dC/8xNk5gjZO4pw="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Cancel-Lock: sha1:B+Qk95Oe4Nny2j9v2ni1fu49M5U=
Content-Language: en-US
In-Reply-To: <trvq8l$4aaj$2@dont-email.me>
 by: Arne Vajhøj - Wed, 8 Feb 2023 15:23 UTC

On 2/8/2023 4:33 AM, servoloro wrote:
> On 2/8/23 10:31, servoloro wrote:
>> *Newbie question*
>> I have to convert a string from the format (how it's called ?)
>> \uXXXX
>> to (again:how it's called ?)
>> %XX%XX
>> i.e. from \u00dc to %C3%9C.
>> Apart from doing a dumb replaceAll
>> I'm sure there is a smarter way.
>> Not knowing the names of the formats Google didn't help me :-(
>> Could someone give me hints/directions ?
> Sorry it is:
> > s=s.replaceAll("\\\\u00dc", "%C3%9C");

There are a lot complications here.
- "\u00dc" is 1 char but "\\u00dc" is 6 chars
- you seems to have an implicit assumption about UTF-8 encoding
- the type of encode is generally known as URL encode, but
there is some ambiguity in that like whether you want
spaces as is or converted to plus sign

But the code below should illustrate a lot.

Arne

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class UFun {
private static String encode_hack(String s) {
return s.replace("\u00dc", "%C3%9C")
.replace("\u00c6", "%C3%86")
.replace("\u00d8", "%C3%98")
.replace("\u00c5", "%C3%85")
.replace("\u00e6", "%C3%A6")
.replace("\u00f8", "%C3%B8")
.replace("\u00e5", "%C3%A5");
}
private static String encode_manual(String s) throws
UnsupportedEncodingException {
StringBuilder sb = new StringBuilder();
for(byte b : s.getBytes("UTF-8")) {
if(32 <= b && b < 127) {
sb.append((char)b);
} else if (0 <= b && b < 10) {
sb.append("%0");
sb.append(Integer.toHexString(b).toUpperCase());
} else {
sb.append('%');
sb.append(Integer.toHexString(b & 0xFF).toUpperCase());
}
}
return sb.toString();
}
private static String encode_builtin(String s) throws
UnsupportedEncodingException {
return URLEncoder.encode(s, "UTF-8").replace("+", "
").replace("%3A", ":");
}
private static void test1(String s) throws
UnsupportedEncodingException {
String s2a = encode_hack(s);
System.out.printf("%s -> %s\n", s, s2a);
String s2b = encode_manual(s);
System.out.printf("%s -> %s\n", s, s2b);
String s2c = encode_builtin(s);
System.out.printf("%s -> %s\n", s, s2c);
}
private static final Pattern p =
Pattern.compile("\\\\u([0-9A-Fa-f]{4})");
private static String decode(String s) {
Matcher m = p.matcher(s);
StringBuffer res = new StringBuffer();
while (m.find()) {
m.appendReplacement(res, Character.toString((char)
Integer.parseInt(m.group(1), 16)));
}
m.appendTail(res);
return res.toString();
}
private static String decode_encode_hack(String s) {
return encode_hack(decode(s));
}
private static String decode_encode_manual(String s) throws
UnsupportedEncodingException {
return encode_manual(decode(s));
}
private static String decode_encode_builtin(String s) throws
UnsupportedEncodingException {
return encode_builtin(decode(s));
}
private static void test2(String s) throws
UnsupportedEncodingException {
String s2a = decode_encode_hack(s);
System.out.printf("%s -> %s\n", s, s2a);
String s2b = decode_encode_manual(s);
System.out.printf("%s -> %s\n", s, s2b);
String s2c = decode_encode_builtin(s);
System.out.printf("%s -> %s\n", s, s2c);
}
public static void main(String[] args) throws
UnsupportedEncodingException {
test1("This is \u00dc and Ü and Danish: ÆØÅæøå");
test2("This is \\u00dc and Ü and Danish: ÆØÅæøå");
}
}

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor