> Ive sent some data via asocket to another app and when it returns the
> data it contains two [][] squares at the start.
No, it doesn't. The data just contains numbers in the form of bits and
bytes. It is a matter of interpretation how these numbers are visually
represented. Most likely you try to print the data as-is, and the
current font has no glyph for the corresponding codes. In such a case
Java happens to print squares. But there are no squares in the data - it
is just that Java decides to represent the particular numbers as squares
for lack of a better representation.
> how can I get rid of
> these squares i thought they might be \r or \n's but there not
Maybe they are. Get a debugger and look at them. Or use a print
statement to print out the codes (not the glyphs, but the numbers). Or
use a network sniffer like ethereal to verify that you indeed have the
data one the wire which you think you have.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
Tim Ward - 27 Jun 2005 15:38 GMT
> > Ive sent some data via asocket to another app and when it returns the
> > data it contains two [][] squares at the start.
[quoted text clipped - 6 lines]
> is just that Java decides to represent the particular numbers as squares
> for lack of a better representation.
Could this be a BOM? - I'd have thought, however, that any Jave Unicode
streaming stuff that he might be using would have known how to deal with
that.
--
Tim Ward
Brett Ward Limited - www.brettward.co.uk
Thomas Weidenfeller - 27 Jun 2005 16:41 GMT
> Could this be a BOM?
That's for sure possible, yes, but how could we know? All we know is
that the OP reads from a socket, but we don't know how it is read. We
also don't know how the data was written (text or binary) at the other end.
We both suggested to sniff the traffic, and that is IMHO the most
sensible way to start.
> - I'd have thought, however, that any Jave Unicode
> streaming stuff that he might be using would have known how to deal with
> that.
That is definitely not the case. See
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
Someone has even copied workaround code from an old discussion in this
group into the bug report. Still after four years Sun hasn't fixed this.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
Mike Schilling - 28 Jun 2005 00:03 GMT
>> > Ive sent some data via asocket to another app and when it returns the
>> > data it contains two [][] squares at the start.
[quoted text clipped - 10 lines]
> streaming stuff that he might be using would have known how to deal with
> that.
Maybe not. Microsoft sometimes uses a BOM to announce "UTF-8 follows";
that's non-standard and Java won't interpret it as such. (Though their
UTF-8 BOM is three bytes.)
james.fitzjohn@gmail.com - 27 Jun 2005 15:52 GMT
Yes I was sure that they were some sort of undisplayable character such
as a tab or lf, but how do I get rid off them?
Im sure the other app isnt sending those characters
Tim Ward - 27 Jun 2005 16:21 GMT
> Yes I was sure that they were some sort of undisplayable character such
> as a tab or lf, but how do I get rid off them?
>
> Im sure the other app isnt sending those characters
How are you sure? You've sniffed the traffic on the wire?
--
Tim Ward
Brett Ward Limited - www.brettward.co.uk
>Ive sent some data via asocket to another app and when it returns the
>data it contains two [][] squares at the start. how can I get rid of
>these squares i thought they might be \r or \n's but there not
Most likely those two squares are the unicode byte order marks. You
simply have to notice them and not try to display them.
See http://mindprod.com/jgloss/unicode.html for an explanation.
see also http://mindprod.com/jgloss/encoding.html

Signature
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm
Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
Mickey Segal - 28 Jun 2005 12:32 GMT
> See http://mindprod.com/jgloss/unicode.html for an explanation.
The Unicode Java applet referred to there:
http://mindprod.com/jgloss/reuters.html
no longer works, though the applet below displaying the source code does
work.
Mickey Segal - 29 Jun 2005 14:43 GMT
> The Unicode Java applet referred to there:
> http://mindprod.com/jgloss/reuters.html
> no longer works, though the applet below displaying the source code does
> work.
Roedy Green has this working again, with the Unicode Java applet referred to
on http://mindprod.com/jgloss/reuters.html
now at http://mindprod.com/applets/unicode.html.
Thanks for the help guys, the server was sending a \r\n and the java
string didnt know what to do with it