Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #36970 > unrolled thread

Anyone know anything about string encodings?

Started byEric Douglas <e.d.programmer@gmail.com>
First post2017-07-20 13:22 -0700
Last post2017-07-20 20:18 -0400
Articles 4 on this page of 24 — 7 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Anyone know anything about string encodings? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-20 13:22 -0700
    Re: Anyone know anything about string encodings? Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2017-07-20 17:03 -0500
      Re: Anyone know anything about string encodings? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-21 06:07 -0700
      Re: Anyone know anything about string encodings? Arne VajhĂžj <arne@vajhoej.dk> - 2017-07-21 19:47 -0400
        Re: Anyone know anything about string encodings? Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2017-07-22 12:20 -0500
          Re: Anyone know anything about string encodings? Arne VajhĂžj <arne@vajhoej.dk> - 2017-07-22 16:40 -0400
            Re: Anyone know anything about string encodings? Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2017-07-24 09:27 -0500
              Re: Anyone know anything about string encodings? Arne VajhĂžj <arne@vajhoej.dk> - 2017-07-24 10:54 -0400
                Re: Anyone know anything about string encodings? Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2017-07-24 16:04 -0500
                  Re: Anyone know anything about string encodings? lewbloch@gmail.com - 2017-07-24 17:40 -0700
                    Re: Anyone know anything about string encodings? Arne VajhĂžj <arne@vajhoej.dk> - 2017-07-25 09:16 -0400
                  Re: Anyone know anything about string encodings? Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2017-07-25 11:50 +0300
                    Re: Anyone know anything about string encodings? Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2017-07-25 11:51 +0300
                      Re: Anyone know anything about string encodings? Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2017-07-25 09:39 -0500
                        Re: Anyone know anything about string encodings? Arne VajhĂžj <arne@vajhoej.dk> - 2017-07-25 14:34 -0400
                    Re: Anyone know anything about string encodings? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2017-07-25 13:07 +0200
                    Re: Anyone know anything about string encodings? Arne VajhĂžj <arne@vajhoej.dk> - 2017-07-25 09:12 -0400
                      Re: Anyone know anything about string encodings? Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2017-07-25 18:05 +0300
                        Re: Anyone know anything about string encodings? Arne VajhĂžj <arne@vajhoej.dk> - 2017-07-25 14:31 -0400
                      Re: Anyone know anything about string encodings? lewbloch@gmail.com - 2017-07-26 11:23 -0700
    Re: Anyone know anything about string encodings? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-20 18:09 -0400
      Re: Anyone know anything about string encodings? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-21 06:09 -0700
        Re: Anyone know anything about string encodings? Arne VajhĂžj <arne@vajhoej.dk> - 2017-07-21 19:46 -0400
    Re: Anyone know anything about string encodings? Arne VajhĂžj <arne@vajhoej.dk> - 2017-07-20 20:18 -0400

Page 2 of 2 — ← Prev page 1 [2]


#36972

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2017-07-20 18:09 -0400
Message-ID<okr9ef$i8i$1@dont-email.me>
In reply to#36970
On 7/20/2017 4:22 PM, Eric Douglas wrote:
> I get an internet stream, in this case a signature from the G Suite Google feed.
> It returns from this method:
> org.apache.http.HttpResponse.getEntity().getContent()
> 
> Then I try to pass it into org.apache.commons.io.IOUtils.toString().
> This method accepts a stream and a charset to return a String.
> 
> I tried to pass it a null and it took the default, which on our system came up with "windows-1252", and the new signatures looked wrong.
> I passed in "UTF-8" and they look right, at least for now.  Will this always work, or how would I choose what charset it should convert with?

     Just guessing:

	https://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/HttpEntity.html#getContentEncoding()

(Disclaimer: I have almost no personal experience with these Apache
packages -- Apacheges?)

-- 
esosman@comcast-dot-net.invalid
Twelve hundred eighty days to go.

[toc] | [prev] | [next] | [standalone]


#36975

FromEric Douglas <e.d.programmer@gmail.com>
Date2017-07-21 06:09 -0700
Message-ID<613854ea-ab12-4a09-a0b8-93b426f76f86@googlegroups.com>
In reply to#36972
On Thursday, July 20, 2017 at 6:09:14 PM UTC-4, Eric Sosman wrote:
>      Just guessing:
> 
> 	https://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/HttpEntity.html#getContentEncoding()
> 

I did try that method, it returns a null.

[toc] | [prev] | [next] | [standalone]


#36977

FromArne VajhĂžj <arne@vajhoej.dk>
Date2017-07-21 19:46 -0400
Message-ID<oku3oc$m19$1@gioia.aioe.org>
In reply to#36975
On 7/21/2017 9:09 AM, Eric Douglas wrote:
> On Thursday, July 20, 2017 at 6:09:14 PM UTC-4, Eric Sosman wrote:
>>       Just guessing:
>>
>> 	https://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/HttpEntity.html#getContentEncoding()
>>
> 
> I did try that method, it returns a null.

I think that one only returns the HTTP header content type encoding.

Arne

[toc] | [prev] | [next] | [standalone]


#36973

FromArne VajhĂžj <arne@vajhoej.dk>
Date2017-07-20 20:18 -0400
Message-ID<okrh85$1iig$1@gioia.aioe.org>
In reply to#36970
On 7/20/2017 4:22 PM, Eric Douglas wrote:
> I get an internet stream, in this case a signature from the G Suite Google feed.
> It returns from this method:
> org.apache.http.HttpResponse.getEntity().getContent()
> 
> Then I try to pass it into org.apache.commons.io.IOUtils.toString().
> This method accepts a stream and a charset to return a String.
> 
> I tried to pass it a null and it took the default, which on our
> system came up with "windows-1252", and the new signatures looked wrong.
> I passed in "UTF-8" and they look right, at least for now. Will this
> always work, or how would I choose what charset it should convert with?

You implement the following logic:

read all or at least a few thousand bytes from stream to byte array
create temp string from byte array using ASCII
encoding = ISO-8859-1
if temp string contains charset info then
     encoding = that charset info
else if HTTP conten type has charset info then
     encoding = that charset info
end if
create string from byte array and remaining stream using found encoding

Arne


[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.java.programmer


csiph-web