I want to remove all special symbols from string and have only words in string like this :
I want to displaye it inside my flutter app on chips , any solution And thanks
Related
How can I convert string to HTML encoded string in Flutter.
This is an example string
This is the sample text & special character
also new line
I want to convert like this
This is the sample text & special character <br> also new line
Not only & I want all of the HTML entities available.
I found HTML to string everywhere But not String to HTML anywhere! I want reversed/opposite feature what html_unescape: provide!
I think this is what you're looking for:
https://api.flutter.dev/flutter/dart-convert/HtmlEscape-class.html
I am using magicsuggest as a auto-complete plugin of a web application with web2py. I define a list variable dt=['张','李'] in the model/db.py. The element in the list is Chinese. However when I embeded the variable in the html like{{=XML(dt)}} according to the manual book of magicsuggest. The chinese character was garbled. After several days searching, I find the list variable with chinese character was encode into hex in the html. I know there is something wrong about encode/decode. Could someone help me to display the correct chinese character in the html?
XML() is meant to take a string, not a list of strings. If you pass it something other than a string, it will first be converted to a string, so your code is equivalent to {{=XML(str(dt))}}, and you'll notice that in Python, str(['张','李']) yields "['\\xe5\\xbc\\xa0', '\\xe6\\x9d\\x8e']".
Instead, you can do {{=XML(dt[0])}}, and you will see the first character in the list displayed properly.
If you want to display a comma separated list surrounded by brackets, you can do:
{{=json.dumps(dt, encoding="UTF-8", ensure_ascii=False)}}
I've a JSON containing some HTML contents from an External System. We have a Rich Text field for storing this HTML data. But I noticed, while storing I'm getting some HTML tags included in to the field as the HTML contents are coming as JSON string. So my question is how can I store the received JSON string data as a HTML back in Netsuite field. Is it possible ?
Jdata = dataIn.desc; // getting something like : Guest(s) benifit's surcharges <br><p>test benifit desc 25% discountpop "test"</p>
Thanks for your interest !
Maybe try unescape or decodeuri, which are standard old js methods.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape
If not just do a string replacement on the known char sets (" being the same as ")
When I try to show the JSON string, the indentation is gone and very ugly.
Is there a way to make it look better?
As you stated in a comment : the JSON string looks good in a browser. That is propably (I'm 99% sure) because most browsers will recognize the content as JSON and display it nicely, in an easier to read form. But in its core, the JSON string is just a set of characters, without any special whitespace characters like /n or /t to indicate newlines or tabs.
So to answear your question : in order to display your JSON string similarily to what you see in your browser, you'd have to parse and format it yourself.
If you are using a CCLabel to display it, you could subclass it creating a JSONLabel which would format a string given in its constructor the way that you like it.
I'm parsing some HTML using Beautiful Soup, and occasionally the HTML it returns includes some special characters, such as — (long dash) and ® (register symbol).
I'm currently storing this html as a string in my db as is, and as a result when I display these variables in my templates the special characters appear as they do above. I've tried unescaping the characters using {{ variable|safe }} but that didn't work.
What is the right way to store, and then display, these types of special characters in Django?
What you're looking for is here:
http://www.crummy.com/software/BeautifulSoup/documentation.html#Entity Conversion
You'll want to use the convertEntities parameter and encode them as unicode.
The final line should be something like
decodedString=unicode(BeautifulStoneSoup(encodedString,convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
To display them again
"Your string with a long dash in it".encode('ascii', 'xmlcharrefreplace')