• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to handle the text which is copied from doc file

 
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, here is a strange problem with special characters which are copied from the microsoft document file to a textarea .

yes, there is a difference in copying from word file and direclty typing the text into the text area

for example if we copy single quote and double quote from a word file into text area and if we insert the text into datbase table and if we retrieve back from the datbase file it will be different.


that means the text which (contains single quotes and double quotes)is copied from the word file will be treated as unknown characters by the textarea.

so there is a problem with text area.

there might be some solution for this.
can any one please help me
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your data is already in one or more strings, one possibility would be the String replace( oldchar, newchar ) method repeated for each of those ghastly "smart" characters that Word uses.
Remember that replace creates a new String if any match is found.
Bill
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
YES,YES,YES you are perfectly correct
i have used the same technique for this issue

greate suggestion

but unfortunatley this leads to performance degrading in big applications and when ever user needs to handle huge text(data) as input from the end user

here is the complete code which takes the input from a jsp page(textarea) and inserts into datbase and then retrieve back from the the databse and displays in th jsp page

please take some time to view my code because this is really Very IMPORTANT issue for all the people who is going to copy the text from word file and paste it into textarea .







but unfortunatley this code is also not going to help all the developers becasue the scan codes which i have got is different from my friends system (they are not independent)

i got 145,146,147,148 fro single quotes and double quotes but in my frnds system some otehr numbers i got

so, with this i can say that by just using replace method we cannot obtain the solution

there must be soem other way for this problem

if anybody know about this problem or overcome this problem please let me know the solution

thanks for your help in advance

regards
saikrishna
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know of no way around it, you have to find out every single one of the possible oddball codes and their replacements and handle them one at a time. You might be able to speed things up by checking for more than one character at a time - take a look at the source for the String.replace method for inspiration.

Please note that the slowest thing in the code you show is probably the getting a separate database connection for each request. In production code you would certainly use a connection pool.

Dont assume you have a performance problem until you have run tests. How big are these chunks of text anyway?

Bill
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i dont understand the question - tell me what you get when you try to save this string to the database and bring it back.

the quic'k bro"wn fox
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lynette Dawson:
i dont understand the question - tell me what you get when you try to save this string to the database and bring it back.

the quic'k bro"wn fox



some inverted question marks in the jsp page
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by William Brogden:
I know of no way around it, you have to find out every single one of the possible oddball codes and their replacements and handle them one at a time. You might be able to speed things up by checking for more than one character at a time - take a look at the source for the String.replace method for inspiration.

Please note that the slowest thing in the code you show is probably the getting a separate database connection for each request. In production code you would certainly use a connection pool.

Dont assume you have a performance problem until you have run tests. How big are these chunks of text anyway?

Bill



hey, the textarea has got lot of data 1000's of characters
so i need to apply this logic to all the text fields and textarea of all the jsp pages
nearly hundereds of fields

so is ther any otherway to overcome this problem
 
Ranch Hand
Posts: 38
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

just quick idea - I'm not sure I understand the "pasting from word to textarea" part - but it does sound like a character set / special characters issue

In your oracle driver config, have you set the charset to use UTF8 ?? if not that might be part of your problem

HTH
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

so is ther any otherway to overcome this problem


If this was my problem I would create a method

String fixDumbSmartChars( String )

Which would:


Bill
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cant you use regex to replace in string?
 
reply
    Bookmark Topic Watch Topic
  • New Topic