diff --git a/src/HtmlAgilityPack.Shared/HtmlEntity.cs b/src/HtmlAgilityPack.Shared/HtmlEntity.cs
index 5e56f8b..331851a 100644
--- a/src/HtmlAgilityPack.Shared/HtmlEntity.cs
+++ b/src/HtmlAgilityPack.Shared/HtmlEntity.cs
@@ -3,7 +3,7 @@
// Forum & Issues: https://github.com/zzzprojects/html-agility-pack
// License: https://github.com/zzzprojects/html-agility-pack/blob/master/LICENSE
// More projects: http://www.zzzprojects.com/
-// Copyright © ZZZ Projects Inc. 2014 - 2017. All rights reserved.
+// Copyright © ZZZ Projects Inc. 2014 - 2017. All rights reserved.
using System;
using System.Collections;
@@ -788,10 +788,11 @@ public static string Entitize(string text, bool useNames, bool entitizeQuotAmpAn
if ((code > 127) ||
(entitizeQuotAmpAndLtGt && ((code == 34) || (code == 38) || (code == 60) || (code == 62))))
{
- string entity;
- EntityName.TryGetValue(code, out entity);
+ string entity = null;
+ if (useNames)
+ EntityName.TryGetValue(code, out entity);
- if ((entity == null) || (!useNames))
+ if (entity == null))
{
sb.Append("" + code + ";");
}
@@ -859,4 +860,4 @@ private enum ParseState
#endregion
}
-}
\ No newline at end of file
+}