Render Emoji HTML Entity stored in database in Django? - html

I've stored the following HTML Entity (🌶🌶) in varchar and is calling it from the database. And then using a for block in the HTML.
However, when the page is rendered, it is displayed as 🌶 instead of the red pepper, I was hoping for.
Am wondering how the amp; got inserted.
Want 🌶 but got 🌶

Try marking the output as |safe.
Only do this if the database code is something you control and you know it is actually safe.
Read me here from the Django Docs: https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#std:templatefilter-safe

Related

In Mediawiki, between PAGENAME, PAGENAMEE and urlencode, which one is actually stored in the Page table?

In the pages I've checked, they all return the same thing, but the Mediawiki documentation says there are differences.
I'm not worried about the differences, but which one is actually stored in the page table?
Neither of them. The internal representation ("DB key form") is title without namespace (it's stored separately as a number in page_namespace), spaces replaced with underscores. The code is here. Thus it's neither {{PAGENAME}} which is human-readable title, nor {{PAGENAMEE}} which is {{#urlencode:{{PAGENAME}}}} with special case for spaces -> underscores.
Got it. I saved the page "Texas A & M" and in the page table it shows as "Texas_A_&_M".
According to Mediawiki's Manual:PAGENAMEE_encoding page (I can't post more than two links), PAGENAME is the only one that will convert an ampersand to & while the others convert it to %26.
The following is still not correct!
I thought it was PAGENAME, but PAGENAME actually doesn't replace the spaces with underscores.
Instead, I found here and here that you can access the string that is stored in the Page table by using this:
$dbk = $title->getDBkey();
That snippet is pulled straight from Mediawiki code.
It doesn't appear there is a Magic Word associated with this key.
I can't find where the page_title in the database comes from, but it looks like it's simply the page name with the spaces, quotes, and ampersand replaced. Maybe it's database dependent. I'm using MySQL.

Display correct characters when Select on column containing HTML

In my database I store some html code (from CKEditor), and I would like to be able to check these values in PhpMyAdmin.
There is one small problem : the HTML is written in french so there are a lot ar &eacute: or other kind of html characters that make the values hard to read.
I know there are settings to avoid CKEditor replacing the characters with &eacute:, but I do not want to change anything in the code or configuration tight now.
Is there any MySQL command that would allow to display the text correctly?
Note : doing a str_replace or kind is not wanted.
Edit :
For exemple for an element stored as follow :
<div>
&eacute:l&eacute:phant
</div>
I would like to read in my result column :
<div>
éléphant
</div>
I'm afraid there is no way to do directly what you are asking for.
The best way I've found would be to create a function which decodes the text, and then use it in select statements:
mysql> SELECT HTML_UnEncode('Dr.Hübner');
+---------------------------------+
| HTML_UnEncode('Dr.Hübner') |
+---------------------------------+
| Dr.Hübner |
+---------------------------------+
Here is the link to that function:
http://forums.mysql.com/read.php?98,246527,246527
This is easily accomplished with phpMyAdmin's transformation feature.
My answer assumes you already have a properly configured phpMyAdmin Configuration Storage, if not you just have to create the tables by editing the file in examples/create_tables.sql to set a username, database name, and password, then import that to your MySQL server. Edit config.inc.php to add the directives you can find listed beginning at http://docs.phpmyadmin.net/en/latest/config.html#cfg_Servers_pmadb .
Before:
Anyway, edit your table by going to the Structure tab.
Click the pencil icon/Change link for the column(s) containing the HTML entities.
On the resulting page, look for the "Browser display transformation" dropdown. One of the built in transformations is exactly what you're after: "Text/Plain: Formatted"
Click Save, then you can Browse the table and should see the transformed output.
After:

Chinese character doesn't support on ActionScript3

actually I try to insert Chinese data to sqlite3 from ActionScript3 using CGI webservice script. for inserting English data it's working fine. But when I try to insert Chinese data, the URL goes like this /cgi-bin/reg.cgi?username=%E5%A5%A0%E5%9F%BA%E6%95%88%E6%9E%9C%E5%9B%BE
and python script shows that update Error. I just googled and got a idea to use encodeURIComponent("奠基效果图"); . When I use encodeURIComponenet it's insert data into my database as like this %E5%A5%A0%E5%9F%BA%E6%95%88%E6%9E%9C%E5%9B%BE . And also I tried byteArray.writeUTF("奠基效果图"); , but when use writeUTF() my URL value goes Null. I think I need to use encode UTF-8. But I don't know how to use that on Action Script. kindly some one suggest some idea to solve this problem. thanks in advance.
Do not think about the format which is stored in the Data Base, when you use the encodeURIComponenet(str) for encoding data, you just use decodeURIComponent(rstr) for retrieve from data base. it can retrieve the data with decoded fromat. I think this one helps.

how to show special characters on my site?

I am currently working on a site that connects a DB and bring the information, some of this information has special characteres because is in polish languague, for example, in the database I have this one ę and I get e printed at my web,I already added the meta
<meta charset="ISO-8859-2">
but doesnt work, only if I write & #281; which is not pract and needs a lot of work, my question is if somebody did this , get the character, like ę, and print it just like that?
Thanks.
Make sure that:
the data really is in ISO-8859-2
the data isn't be corrupted by the configuration of the database
the HTTP headers aren't claiming the data is encoded a different way
whatever you are using to pull the data out of the database isn't transcoding it
You should also ditch ISO-8859-2 (as it is very legacy) and move to UTF-8.
Use a Unicode entity. &#xxxx; where xxxx is the Unicode value for the character.

Get correct output from UTF-8 stored in VarChar using Entity Framework or Linq2SQL?

Borland StarTeam seems to store its data as UTF-8 encoded data in VarChar fields. I have an ASP.NET MVC site that returns some custom HTML reports using the StarTeam database, and I would like to find a better solution for getting the correct data, for a rewrite with MVC2.
I tried a few things with Encoding GetBytes and GetString, but I couldn't get it to work (we use mostly Delphi at work); then I figured out a T-SQL function to return a NVarChar from UTF-8 stored in a VarChar, and created new SQL views which return the data as NVarChar, but it's slow.
The actual problem appears like this: “description†instead of “description”, in both SSMS and in a webpage when using Linq2SQL
Is there a way to get the proper data out of these fields using Entity Framework or Linq2SQL?
Well, once you get the data out, you could always try this:
Encoding.UTF8.GetString(Encoding.Default.GetBytes(item.Description))
assuming the field is encoded in the system ANSI page. You might have to create the right encoding with Encoding.GetEncoding() if for some reason it isn't (looked up from DB type, for example).