Removing those square bytes from a string

A

Arun

I am trying to take a string from a JTextArea box and then convert it
to a document model.

It works with most text that i load to it but not to one particular
file... this is because it has those square symbols that u see when u
open an .exe in a text editor.
What can i do to rid of these characters from a string?
 
A

Ann

Arun said:
I am trying to take a string from a JTextArea box and then convert it
to a document model.

It works with most text that i load to it but not to one particular
file... this is because it has those square symbols that u see when u
open an .exe in a text editor.
What can i do to rid of these characters from a string?

Is it from a "string from a JTextArea box" or is it "one particular file"
or is it something else?
 
A

Andrew Thompson

I share Ann's confusion as to what you want. This may be partly
due to a lack of expertise at English, but is not assisted by trimming
*all* of the previous text. It is best to quote a little to give
answers a context, as I have done above.

(OP earlier)
What can i do to rid of these characters from a string?

Generally you would look for a Font that supports those characters,
assuming that what you have loaded is actually 'string' information.
this is because it has those square symbols that u see when u
open an .exe in a text editor.

Which a .exe file is most definitely *not*.

You should not be attempting to edit binary data as if it were a
string. If you mean files, "like, but not actually .exe's"
then please be more specific. What files exactly?
 
H

Harish

my guess is the eol '\n\r' that u get from a file....
jtextarea may be printing it as a square box....
 
A

Andrew Thompson

my guess ..

Stop guessing, you are not very good at it.

While you are at it, please..
- quote *below* what you are responding to.
- find your Shift key and use it at the start of every sentence
..is the eol '\n\r' that u

- avoid 'kewl' abbreviations like 'u', the word is 'you'.
..get from a file....

JTextArea will correctly interpret EOL's whether they
are \n, \r, or \n\r.
jtextarea may be printing it as a square box....

No.

I suggest you prepare a code example[1] and zip it up
with an example *short* file that is causing problems.
Upload the .zip (to Geocities or such) and give us the link.

[1] <http://www.physci.org/codes/sscce.jsp>
 
S

Sudsy

Fred said:
Your .signature is pretty long for a guy giving etiquette lessons.

5 lines is perfectly acceptable. A couple or three more and you
would have cause for complaint. Have you checked out some of his
sites, BTW?
 
H

Harish

Andrew Thompson said:
Stop guessing, you are not very good at it.

Perhaps you can add one more rule: take personal comments out of a tech
discussion
hmm....some people!!!
While you are at it, please..
- quote *below* what you are responding to.
- find your Shift key and use it at the start of every sentence
<http://www.physci.org/kbd.jsp?key=shift>
..and..

If you are trying to increase web traffic and page rank of ur sites, do
this:
have a web page for all the words in your vocabulary, and then put links to
each of them instead...

i feel wretched ....
 
A

Ann

Arun said:
I am trying to take a string from a JTextArea box and then convert it
to a document model.

It works with most text that i load to it but not to one particular
file... this is because it has those square symbols that u see when u
open an .exe in a text editor.
What can i do to rid of these characters from a string?

qstring = qstring.replaceAll()
 
A

Arun

I share Ann's confusion as to what you want. This may be partly
due to a lack of expertise at English, but is not assisted by trimming
*all* of the previous text. It is best to quote a little to give
answers a context, as I have done above.

This was google groups fault, i replied using their beta google groups
reply function and know that there was content before i submitted the
reply.

Which a .exe file is most definitely *not*.

You should not be attempting to edit binary data as if it were a
string. If you mean files, "like, but not actually .exe's"
then please be more specific. What files exactly?

I said the string has those characters (which i don't know the name of)
that come up if you happen to open up .exe's.
It shouldn't matter what the string is, i just simply want to rid of
these characters.

The string comes from an xml ant build file which builds an application
named Antidote. I am using it as a test file for my own application.

So put simply, i have a string, it has those square symbols in them, do
you know how to rid of them?

If you don't know the answer i suggest you not waste your time replying
which such pointless posts.
 
R

Rusty Wright

In the old days of 7 bit ascii those boxes would be from bytes that
aren't part of the ascii character set and therefore couldn't be
displayed so displaying little boxes is their way of punting. If you
want to just be able to display any arbitrary file, .exe or whatever,
and not get those little boxes and only display the bytes/ints that
have displayable text you'll need to look at Java's char or character
stuff and figure out how to filter out the "crap". For example, C has
a ctype thing and you can do things like isascii(c), isalnum(c),
isprint(c), etc. You'll have to figure out how to do something
similar in Java but it's probably not as clunky as how you'd do it in
C.
 
P

Peter Davis

I am trying to take a string from a JTextArea box and then convert it
to a document model.

It works with most text that i load to it but not to one particular
file... this is because it has those square symbols that u see when u
open an .exe in a text editor.
What can i do to rid of these characters from a string?

You're treading on very dangerous ground... you're asking to write code
to destroy information, which will inevitably lead to customer
complaints when your application destroys information that it shouldn't.

The better question is why those "square" characters are there in the
first place. Are you trying to display a .exe file? Better to use a
HEX editor.

The better solution is to install a font that can display the
characters correctly. The problem is that the "square" characters will
be different for just about every computer, because some will have, for
example, Chinese fonts that will display thousands of additional
characters that your standard Windows 95 won't. The only way to delete
all "square" characters in all situations is to delete everything that
is not standard 7-bit ASCII, but then you can't even handle text with
accénts lìké thîs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top