Tag Info

Hot answers tagged

12

< and > are encoded as +ADw- and +AD4- in UTF-7. Now imagine the following: Someone sends +ADw-script+AD4-alert(+ACI-Hello+ACI-)+ADw-/script+AD4- as comment text. It will pass all validation unescaped. The database expects and treats all incoming data as UTF-8. Since all UTF-7 streams are valid UTF-8 too, this will never result in a SQL error, and ...


6

See the discussion for Taxonomy Short Description for a better way to shorten a string. I’m not aware of a WP function that is getting truncation right. Here is my code based on the linked discussion: /** * Shortens an UTF-8 encoded string without breaking words. * * @param string $string string to shorten * @param int $max_chars maximal ...


5

Interesting question. This could be a useful part of a specific language file. It cannot be done in CSS, because CSS is (mostly) character agnostic. But using a filter and PHP it is possible and on topic: add_filter( 'the_content', 't5_chinese_spacing' ); function t5_chinese_spacing( $content ) { return preg_replace( ...


3

It happens because when you save a post, WordPress calls sanitize_title function to sanitize your title. This function applies sanitize_title filter. One of core hooks for sanitize_title filter is sanitize_title_with_dashes function, which checks title on utf8 format by calling seems_utf8 function and if the title has utf8 format, the function call ...


3

So after about a year (on and off!) I had managed to hopefully get a fix on encoding issue. Why it breaks What my experience boiled down to, is that encoding issue like this are mostly caused by miscommunication when moving data around. in best case this is read mismatch, when correct data is wrongly interpreted in worst case that is write mismatch, when ...


3

My guess is that you pasted something from a Windows environment and that's the CR (carriage return, I think) character. I'd go into the editor and just remove those line breaks. That should fix the problem. Also, you might look into standardizing the content type meta tag. You've got <meta charset="UTF-8" /> I could be wrong about this, but in ...


2

The problem is an invalid UTF-8 character in the excerpt <description>. The text is cut off in the middle of a multi-byte character, rendering your complete feed invalid. You get a slightly hint when you look at it in Opera. Do you filter 'bloginfo_rss' or 'get_bloginfo_rss'? Disable all plugins and look if the feed is still broken.


2

After spending the entire day working on this, I finally found a guide that worked perfectly: http://www.blogsuccessjournal.com/blog-tips-and-advice/wordpress-tips-advice/seeing-weird-characters-on-blog-how-to-fix-wordpress-character-encoding-latin1-to-utf8/ Before that, I tried following @Rarst's information, tried exporting the database and manually ...


2

There's a big chance you can fix this by adding 1 line to your .htaccess file AddDefaultCharset off Alternatively replace "off" with the actual charset you want to use.


2

Omar, A good article about charsets can be found at http://codex.wordpress.org/Converting_Database_Character_Sets. Unless you have very specific requirements to the languages you are using, you will want to use charset utf8 with collation utf8_general_ci. The default WP settings are OK for this. I.e. charset definition in wp-config.php will be UTF-8. No ...


2

The reason commenting out (see q ) didn't work is that the data was wrong in the database, so no encoding change could fix it. I restored the database by copy pasting the sql script into PHPMyAdmin, and the text box interpreted the text as having the wrong encoding. By using import in phpmyadmin and selecting the file, that data came in correctly.


2

To output JSON always the function json_encode( $string ). The function is not available on all hosts. Don't worry, WordPress offers a fallback in wp-includes/compat.php. That's a wrapper for class Services_JSON::encodeUnsafe() (see wp-includes/class-json.php). If you take a look at the source you'll see: It's not a trivial job to encode a string. :) There ...


2

Try this: $title = get_post_field('post_title', $post_id, 'raw'); However I'd get to the bottom of what encoding reddit code would prefer. Echoing raw stuff is poor idea for security.


2

Your browser doesn’t send the copied text UTF-8 encoded to the server. On the first character that isn’t UTF-8 compatible, in your example the apostrophe – ’ –, the stream to the data base is broken and not recovered. That’s a browser issue. If I had to guess – well, I have because you didn’t mention it – I would say Internet Explorer. There are two ways to ...


2

According to this page, you can use the tiny_mce_before_init filter, make sure the entity encoding is set to named, and then add whichever special characters you want to the entities array.


2

There are $wpdb->charset and $wpdb->collate. I am not sure if or when one of these values might be empty, so it is better to prepare for empty values … From my DB class: /** * Get table charset and collation. * * @since 2012.10.22 * @return string */ protected static function get_wp_charset_collate() { global $wpdb; $charset_collate = ...


2

UNIX line endings (\n) and UTF-8 are just common code standards. As far as I can see, they are not even mentioned in the Coding Standards. Most (all?) core PHP files are just plain US-ASCII. Try to follow that path to keep your files as compatible as possible. If you use UTF-8, add a line at the start of a PHP file with an Encoding Cookie or file variable: ...


1

PHP itself does not care whether you use DOS or UNIX style line endings in the PHP code sections, because it simply ignores whitespace anyway, so both of those get ignored regardless. PHP interpreters do not know about the existence of Byte Order Marks in files, and so having a BOM at the start of the PHP file will cause that BOM to be output when the PHP ...


1

Using a snippet of code like this: $hook_name = 'the_content'; global $wp_filter; var_dump($wp_filter[$hook_name]); I was able to find a list of all hooked callback functions to the WordPress filter: the_content. I then located a few possible culprits, then searched for their function existence. After narrowing down my list, I came to the conclusion on ...


1

The tip in Part 2 at the site you link that reads Unzip the database you've downloaded and open it with text editor (Notepad++ or Dreamweaver) and use "Find and Replace" option to change "http://olddomain.com" with "http://newdomain.com" and then import it with phpmyadmin. is absolutely wrong. Running a find/replace on a database dump with a text ...


1

Try to change encoding rule to utf8 in your databse. This can easily be done with phpMyAdmin for example. If this does not solve your issue, add encoding attribue to your Html tag. Hope this helps.


1

The antispambot() method is still very reliable and robust from my experience, I have not had many problems using it but something else to look at depending on how far you are willing to go in securing your email address is to look into probably one of the easiest and most effective methods but also least known, believe it or not just requires minor CSS. I ...


1

The file wp-admin/includes/upgrade.php includes wp-admin/includes/schema.php. This at the top declare as global (see source): // Declare these as global in case schema.php is included from a function. global $wpdb, $wp_queries, $charset_collate; ... $charset_collate = ''; if ( ! empty( $wpdb->charset ) ) $charset_collate = "DEFAULT CHARACTER SET ...


1

Thanks, fdsa! For posterity, here's the actual code I used. It adds copyright, registered, trademark, service mark and euro to the array of allowed entities. I'm confused as to why some of these aren't in there by default, as they're really common. But in any case, this works: // Custom configuration for TinyMCE function wpsx_54398_configure_tiny_mce( ...


1

It looks to me like you're not using an actual apostrophe, but one of the curly apostrophes, such as those that Microsoft Word might be configured to auto-correct to. There is a chance that your mysqldump was actually exporting it incorrectly. In my test database, both PowerShell and Command Prompt were dumping as ΓÇÖ, whereas Cygwin was dumping as ’. If ...


1

The problem ended up being (I think) Powershell's wrangling of the output from mysqldump. In powershell, I had been using: mysqldump -u**** -p**** -h**** wordpress --default-character-set=utf8 | out-file out.sql -Encoding UTF8 I was even good about explicitly outputting UTF8 for both mysqldump and out-file! However, it seems (and this is really hard ...


1

This happens because search strings gets url encoded in order for the URL to be valid. You can reverse this with urldecode.


1

No, it is not entirely possible. WordPress is using Percent encoding to sanitise the slug. You could undo this, and it would deliver nonlatin characters, but the browser would immediately swap these out for percent encoded characters when you tried to visit the page. Wether your database will store these characters, and the table encoding is irrelevant, as ...


1

See Converting Database Character Sets in Codex. Article has note about being completely rewritten at 3.0.1 version so info should be up to date.


1

EDIT: Disable magic_quotes_gpc in your server. try adding in .HTACCESS file (if you on shared hosting): php_flag magic_quotes_gpc off If you'll get 500 server error after you added it - delete it and put this: ini_set ('magic_quotes_gpc', 0); in theme's functions.php file. And with function bellow check is it on. You can create php file with this content ...



Only top voted, non community-wiki answers of a minimum length are eligible