Jump to content

Spaces in Textarea appear encoded


joe_ma
 Share

Recommended Posts

Hello

I have a textarea field without FCKEditor with the HTML Entity Encoder active.

Now this leads to the problem, that the spaces in numbers (e.g. telephone numbers) appear encoded in the frontend. Like this:

Tel. 044 461 56 43.

Is there a way to prevent this and keep the entity encoder active?

Link to comment
Share on other sites

Hi @joe_ma,

not sure on this, but have you checked if this has nothing to do with copy pasting data from anywhere else into the textarea field?

Or the otherway round: this behaves the same if you type manually the String "Tel. 044 461"?

I haven't investigated further, but I'm wondering if the PHP entity encoder makes differences between spaces that are wrapped from numeric chars and spaces that are wrapped only from alpha chars or mixed alpha-numeric chars. ???

Link to comment
Share on other sites

Perhaps this can help: https://processwire.com/talk/topic/9465-text-area-outputting-p-tags/.

"I checked that HTML entities was off and it was. 

Oddly enough, enabling and then disabling it again worked and my output is now working."

Can you give us more details on your settings, show us the code that you have in your template (in case)...?

And what happens if you replace "#160;" (Entity Number) with " " (Entity Name)?

Link to comment
Share on other sites

@Horst

Yes, I did check that. Even when I write a number like this manually, it appears encoded in the frontend. The output looks like this:

Pfarrer Christopar Anthonothas Dalima, Tel. 044 461 56 43. Gottesdienste: Jeden 2. und 5. Sonntag um 16.30 Uhr in der Spanischen Mission, Sophiestr. 5, Ostermundigen. Eucharistiefeier jeden 4. Sonntag um 11.30 Uhr in der Pfarrei St. Josef, Stapfenstr. 25, 3097 Köniz.

Note that even the space after the CAP is encoded.

Whereas the textfield looks like this:

Pfarrer Christopar Anthonothas Dalima, Tel. 044 461 56 43. Gottesdienste: Jeden 2. und 5. Sonntag um 16.30 Uhr in der Spanischen Mission, Sophiestr. 5, Ostermundigen. Eucharistiefeier jeden 4. Sonntag um 11.30 Uhr in der Pfarrei St. Josef, Stapfenstr. 25, 3097 Köniz

@Christophe

Yes, I did check and uncheck the encoder, with no results.

And what happens if you replace "#160;" (Entity Number) with " " (Entity Name)?

How can I do this? It is a textarea field without editor. So there is no "HTML" button.

Link to comment
Share on other sites

You can add a textformatter to that Field.

drop the following code into a file named and located at

site/modules/TextformatterRemoveEncodedSpaces/TextformatterRemoveEncodedSpaces.module

<?php
class TextformatterRemoveEncodedSpaces extends Textformatter {

    public static function getModuleInfo() {
        return array(
            'title'    => 'Remove Encoded Spaces ()',
            'version'  => '0.0.1',
            'summary'  => 'Removes that weird encoded spaces (& #160  from my Textareas!'
        );
    }

    public function format(&$str) {

        $search = array(
            ' '
            );

        $replace = array(
            ' '
            );

        $str = str_replace($search, $replace, $str);

    }
}

install it and add it to the output of your textarea field.

  • Like 1
Link to comment
Share on other sites

I now seem to have resolved the problem.

While installing Horst's Module from above, I became aware, that there is also a textformatter module called "Newlines to XHTML line breaks".

So far I used the php function nl2br() for displaying the content of the said field. I now removed that function and installed the "Newlines ..." module, and lo! it works!

@Horst:

So, your module is not even necessary. I appologize for the trouble I caused and I thank you for all your help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...