Linebreak problems when copy&paste from word

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Georg Weiler

    Linebreak problems when copy&paste from word

    Hi,

    I have a form, where the user enters text. After submit, the text is
    then inserted into a PostgreSQL database. So far, so good.

    The problem is, that most of my users copy&paste their text from MS Word
    into the textbox. Now I have these (hidden) linebreaks in the string
    that cause trouble when I furter process the text.

    Is there a way (maybe just a simple PHP command) to get rid of these
    formating things. I presume I would have to kind of "convert" the string
    to unformatted text somehow.

    Thanks for your input,
    georg
  • ZeldorBlat

    #2
    Re: Linebreak problems when copy&paste from word

    Figure out what characters are causing the problem and use
    str_replace():

    <http://www.php.net/manual/en/function.str-replace.php>

    You can then replace any characters you don't want with something else
    (like an empty string). With the weird hidden characters, you may need
    to use ord() and chr() to figure out what the ASCII values are.

    Comment

    • Georg Weiler

      #3
      Re: Linebreak problems when copy&amp;paste from word

      ZeldorBlat wrote:[color=blue]
      > Figure out what characters are causing the problem and use
      > str_replace():
      >
      > <http://www.php.net/manual/en/function.str-replace.php>
      >
      > You can then replace any characters you don't want with something else
      > (like an empty string). With the weird hidden characters, you may need
      > to use ord() and chr() to figure out what the ASCII values are.[/color]

      If you look at the first two 'User Contributed Notes' on this page:

      Convert the first byte of a string to a value between 0 and 255


      Could one of those two help me with my problem (the linebreaks)? I only
      see them removing quotes etc.

      What is the linebreak code, I have ro replace?

      thanks a lot,
      georg

      Comment

      Working...