Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 5871)
+++ /CKEditor/trunk/CHANGES.html	(revision 5872)
@@ -73,4 +73,6 @@
 		<li><a href="http://dev.ckeditor.com/ticket/6188">#6188</a> : [IE7] Automatic color button had the wrong cursor.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/6129">#6129</a> : The show blocks' labels are now shown in the right for RTL languages.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/5421">#5421</a> : &amp;shy; entity not converted when config.entities=false.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/5769">#5769</a> : xhtml code generation problem &amp;nbsp; instead of &amp;#160; (htmlentities, entities,entities_additional,..., configuration).</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.ckeditor.com/ticket/6246">#6246</a> : Chinese Simplified;</li>
Index: /CKEditor/trunk/_source/plugins/entities/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/entities/plugin.js	(revision 5871)
+++ /CKEditor/trunk/_source/plugins/entities/plugin.js	(revision 5872)
@@ -6,9 +6,8 @@
 (function()
 {
+	// Base HTML entities.
+	var htmlbase = 'nbsp,gt,lt,quot';
+
 	var entities =
-
-		// Base HTML entities.
-		'nbsp,gt,lt,quot,' +
-
 		// Latin-1 Entities
 		'iexcl,cent,pound,curren,yen,brvbar,sect,uml,copy,ordf,laquo,' +
@@ -47,5 +46,9 @@
 		'upsih,piv';
 
-	function buildTable( entities )
+	/**
+	 * Create a mapping table between one character and it's entity form from a list of entity names.
+	 * @param reverse {Boolean} Whether create a reverse map from the entity string form to actual character.
+	 */
+	function buildTable( entities, reverse )
 	{
 		var table = {},
@@ -64,29 +67,35 @@
 		entities = entities.replace( /\b(nbsp|shy|gt|lt|amp)(?:,|$)/g, function( match, entity )
 			{
-				table[ specialTable[ entity ] ] = '&' + entity + ';';
-				regex.push( specialTable[ entity ] );
+				var org = reverse ? '&' + entity + ';' : specialTable[ entity ],
+					result = reverse ? specialTable[ entity ] : '&' + entity + ';';
+
+				table[ org ] = result;
+				regex.push( org );
 				return '';
 			});
 
-		// Transforms the entities string into an array.
-		entities = entities.split( ',' );
-
-		// Put all entities inside a DOM element, transforming them to their
-		// final chars.
-		var div = document.createElement( 'div' ),
-			chars;
-		div.innerHTML = '&' + entities.join( ';&' ) + ';';
-		chars = div.innerHTML;
-		div = null;
-
-		// Add all chars to the table.
-		for ( var i = 0 ; i < chars.length ; i++ )
+		if ( !reverse )
 		{
-			var charAt = chars.charAt( i );
-			table[ charAt ] = '&' + entities[ i ] + ';';
-			regex.push( charAt );
+			// Transforms the entities string into an array.
+			entities = entities.split( ',' );
+
+			// Put all entities inside a DOM element, transforming them to their
+			// final chars.
+			var div = document.createElement( 'div' ),
+				chars;
+			div.innerHTML = '&' + entities.join( ';&' ) + ';';
+			chars = div.innerHTML;
+			div = null;
+
+			// Add all chars to the table.
+			for ( var i = 0 ; i < chars.length ; i++ )
+			{
+				var charAt = chars.charAt( i );
+				table[ charAt ] = '&' + entities[ i ] + ';';
+				regex.push( charAt );
+			}
 		}
 
-		table.regex = regex.join( '' );
+		table.regex = regex.join( reverse ? '|' : '' );
 
 		return table;
@@ -99,7 +108,4 @@
 			var config = editor.config;
 
-			if ( !config.entities )
-				return;
-
 			var dataProcessor = editor.dataProcessor,
 				htmlFilter = dataProcessor && dataProcessor.htmlFilter;
@@ -107,14 +113,19 @@
 			if ( htmlFilter )
 			{
-				var selectedEntities = entities;
-
-				if ( config.entities_latin )
-					selectedEntities += ',' + latin;
-
-				if ( config.entities_greek )
-					selectedEntities += ',' + greek;
-
-				if ( config.entities_additional )
-					selectedEntities += ',' + config.entities_additional;
+				// Mandatory HTML base entities.
+				var selectedEntities = htmlbase;
+
+				if ( config.entities )
+				{
+					selectedEntities += ',' + entities;
+					if ( config.entities_latin )
+						selectedEntities += ',' + latin;
+
+					if ( config.entities_greek )
+						selectedEntities += ',' + greek;
+
+					if ( config.entities_additional )
+						selectedEntities += ',' + config.entities_additional;
+				}
 
 				var entitiesTable = buildTable( selectedEntities );
@@ -124,12 +135,24 @@
 				delete entitiesTable.regex;
 
-				if ( config.entities_processNumerical )
+				if ( config.entities && config.entities_processNumerical )
 					entitiesRegex = '[^ -~]|' + entitiesRegex ;
 
 				entitiesRegex = new RegExp( entitiesRegex, 'g' );
+
+				function getEntity( character )
+				{
+					return config.entities_processNumerical == 'force' || !entitiesTable[ character ] ?
+						   '&#' + character.charCodeAt(0) + ';'
+							: entitiesTable[ character ];
+				}
+
+				// Decode entities that the browsers has transformed
+				// at first place.
+				var baseEntitiesTable = buildTable( [ htmlbase, 'shy' ].join( ',' ) , true ),
+					baseEntitiesRegex = new RegExp( baseEntitiesTable.regex, 'g' );
 
 				function getChar( character )
 				{
-					return entitiesTable[ character ] || ( '&#' + character.charCodeAt(0) + ';' );
+					return baseEntitiesTable[ character ];
 				}
 
@@ -138,5 +161,6 @@
 						text : function( text )
 						{
-							return text.replace( entitiesRegex, getChar );
+							return text.replace( baseEntitiesRegex, getChar )
+									.replace( entitiesRegex, getEntity );
 						}
 					});
@@ -180,11 +204,14 @@
 /**
  * Whether to convert all remaining characters, not comprised in the ASCII
- * character table, to their relative numeric representation of HTML entity.
+ * character table, to their relative decimal numeric representation of HTML entity.
+ * When specified as the value 'force', it will simply convert all entities into the above form.
  * For example, the phrase "This is Chinese: &#27721;&#35821;." is outputted
  * as "This is Chinese: &amp;#27721;&amp;#35821;."
  * @type Boolean
+ * @type Boolean|String
  * @default false
  * @example
  * config.entities_processNumerical = true;
+ * config.entities_processNumerical = 'force';		//Convert from "&nbsp;" into "&#160;";
  */
 CKEDITOR.config.entities_processNumerical = false;
