Returns an HTML code corresponding to the specified HTML entity.

@param htmlEntity the HTML entity to transform to the corresponding HTML
code
@return an HTML code corresponding to the specified HTML entity
322778
public static int getHtmlCodeByHtmlEntity(String htmlEntity)
    {
        Entity entity = fHtmlToWiki.get(htmlEntity);
        return entity != null ? entity.fHtmlCode : 0;
    }
465846
public static HtmlTree NOSCRIPT(Content body) {
        HtmlTree htmltree = new HtmlTree(HtmlTag.NOSCRIPT, nullCheck(body));
        return htmltree;
    }
178923
function createEntity(html, id) {
    let $ = parser.load(html)

    let trs = $('.tabproperty table tr').slice(2)

    let states = utils.tableParser(trs, {
        date: {
            idx: 1,
            mandatory: true,
            parser: e => moment.tz(e, "MM/DD/YYYY hh:mm a", zone).format()
        },
        country: {
            idx: 3,
            mandatory: true
        },
        area: {
            idx: 5,
            mandatory: true
        },
        state: {
            idx: 7,
            mandatory: true
        }
    }).map(line => {
        return {
            date: line.date,
            state: line.state,
            area: line.country + ' - ' + line.area
        }
    }).reverse()

    return new EntityInfo({
        id: id,
        states: states
    })
}
471854
public Html getHtml() {
        if (html == null) {
            html = new Html(rawText, request.getUrl());
        }
        return html;
    }
1155366
def html_entity_decode_char(self, m, defs=htmlentities.entitydefs):
        
        try:
            char = defs[m.group(1)]
            return "&{char};".format(char=char)
        except ValueError:
            return m.group(0)
        except KeyError:
            return m.group(0)
1037825
def replace_html_entities(cls, replacement_string):
        
        def _hex_to_unicode(hex_code):
            if PYTHON3:
                hex_code = '{0:0>8}'.format(hex_code)
                as_int = struct.unpack('>i', bytes.fromhex(hex_code))[0]
                return '{0:c}'.format(as_int)
            else:
                return hex_to_unicode(hex_code)

        def _replace_integer_entity(match):
            hex_val = hex(int(match.group(1)))

            return _hex_to_unicode(hex_val.replace('0x', ''))

        def _replace_hex_entity(match):
            return _hex_to_unicode(match.group(1))

        # replace integer code points, &#65;
        replacement_string = re.sub(
            cls._html_entities_integer_unicode_regex,
            _replace_integer_entity,
            replacement_string
        )
        # replace hex code points, &#x41;
        replacement_string = re.sub(
            cls._html_entities_hex_unicode_regex,
            _replace_hex_entity,
            replacement_string
        )

        return replacement_string
479623
def html_to_text(html, base_url='', bodywidth=CONFIG_DEFAULT):
    
    def _patched_handle_charref(c):
        self = h
        charref = self.charref(c)
        if self.code or self.pre:
            charref = cgi.escape(charref)
        self.o(charref, 1)

    def _patched_handle_entityref(c):
        self = h
        entityref = self.entityref(c)
        if self.code or self.pre:  # this expression was inversed.
            entityref = cgi.escape(entityref)
        self.o(entityref, 1)

    h = HTML2Text(baseurl=base_url, bodywidth=config.BODY_WIDTH if bodywidth is CONFIG_DEFAULT else bodywidth)
    h.handle_entityref = _patched_handle_entityref
    h.handle_charref = _patched_handle_charref
    return h.handle(html).rstrip()
693961
public String getHtmlCode()
	{
		Object[] _params =
		{
			SgmlUtils.generateAttribute(HtmlUtils.AttributeNames.VALUE, getValue())
		};
		MessageFormat _format = (isSelected()) ? FORMAT__SELECTED : FORMAT__NOT_SELECTED;
		return _format.format(_params);
	}
103737
function transformHtmlEntities() {
    return function(method, request, next) {
        next(function(response, next) {
            response.body = utils.deHtmlEntities(response.body);
            next();
        })
    };
}
875521
public Entity getEntity(String id) {
        Entity e = getEntities().get(id);
        if (e == null) {
            return null;
        }
        return e;
    }
359621
@Override
    protected RequestEntity generateRequestEntity() {
        if (!this.params.isEmpty()) {
            // Use a ByteArrayRequestEntity instead of a StringRequestEntity.
            // This is to avoid potential encoding issues.  Form url encoded strings
            // are ASCII by definition but the content type may not be.  Treating the content
            // as bytes allows us to keep the current charset without worrying about how
            // this charset will effect the encoding of the form url encoded string.
            String content = EncodingUtil.formUrlEncode(getParameters(), getRequestCharSet());
            ByteArrayRequestEntity entity = new ByteArrayRequestEntity(
                EncodingUtil.getAsciiBytes(content),
                FORM_URL_ENCODED_CONTENT_TYPE
            );
            return entity;
        }
        return super.generateRequestEntity();
    }
1137879
private function convertToHtmlEntities(string $htmlContent, string $charset = 'UTF-8'): string
    {
        set_error_handler(function () { throw new \Exception(); });

        try {
            return mb_convert_encoding($htmlContent, 'HTML-ENTITIES', $charset);
        } catch (\Exception $e) {
            try {
                $htmlContent = iconv($charset, 'UTF-8', $htmlContent);
                $htmlContent = mb_convert_encoding($htmlContent, 'HTML-ENTITIES', 'UTF-8');
            } catch (\Exception $e) {
            }

            return $htmlContent;
        } finally {
            restore_error_handler();
        }
    }
624868
public static String htmlEncode(String content) {
		if (null == content) {
			return "";
		}
		return content.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
	}
452745
protected String getBody(HttpEntity entity, String enc) throws IOException {
    final StringBuilder body = new StringBuilder();
    String buffer = "";
    if (entity != null) {
      final BufferedReader reader =
          new BufferedReader(new InputStreamReader(entity.getContent(), enc));
      while ((buffer = reader.readLine()) != null) {
        body.append(buffer);
      }

      reader.close();
    }
    return body.toString();
  }
1136156
@Pure
	@SuppressWarnings("checkstyle:magicnumber")
	public static String parseHTML(String html) {
		if (html == null) {
			return null;
		}
		final Map<String, Integer> transTbl = getHtmlToJavaTranslationTable();
		assert transTbl != null;
		if (transTbl.isEmpty()) {
			return html;
		}
		final Pattern pattern = Pattern.compile("[&](([a-zA-Z]+)|(#x?[0-9]+))[;]"); //$NON-NLS-1$
		final Matcher matcher = pattern.matcher(html);
		final StringBuilder result = new StringBuilder();
		String entity;
		Integer isoCode;
		int lastIndex = 0;
		while (matcher.find()) {
			final int idx = matcher.start();
			result.append(html.substring(lastIndex, idx));
			lastIndex = matcher.end();
			entity = matcher.group(1);
			if (entity.startsWith("#x")) { //$NON-NLS-1$
				try {
					isoCode = Integer.valueOf(entity.substring(2), 16);
				} catch (Throwable exception) {
					isoCode = null;
				}
			} else if (entity.startsWith("#")) { //$NON-NLS-1$
				try {
					isoCode = Integer.valueOf(entity.substring(1));
				} catch (Throwable exception) {
					isoCode = null;
				}
			} else {
				isoCode = transTbl.get(entity);
			}

			if (isoCode == null) {
				result.append(matcher.group());
			} else {
				result.append((char) isoCode.intValue());
			}
		}
		if (lastIndex < html.length()) {
			result.append(html.substring(lastIndex));
		}
		return result.toString();
	}
642991
def html_entity_decode(self):
        
        pattern = re.compile(r"&#(\w+?);")
        string = pattern.sub(self.html_entity_decode_char, self.my_string)
        return pattern.sub(self.html_entity_decode_codepoint, string)
799265
function _getEntityKey(entityType, entity) {
  switch (entityType) {
    case 'remote-application':
    case 'application':
    case 'unit':
      return entity.name;
    case 'machine':
    case 'relation':
      return entity.id;
    case 'annotation':
      return entity.tag;
    default:
      // This is an unknown entity type so ignore it as we don't know how to
      // handle it.
      return null;
  }
}