श्रेणियाँ, पैकेज और रिपॉज़िटरी खोजें

GitHub रिपॉज़िटरीjames-alex/html_character_entities

html_character_entities

एक डार्ट उपयोगिता क्लास जिसमें HTML 4.01 चरित्र संस्करण के प्रत्येक की-वैल्यू युग्म के मानचित्र हैं, जिसमें एससीआईआई और हेक्स कोड शामिल हैं, और इन चरित्र संस्करणों के बीच तारों को कोड और डीकोड करने के लिए विधियाँ हैं।

html_character_entities प्रोजेक्ट कवर
स्टार
1
फ़ोर्क
2
अंतिम पुश (UTC)
21 अप्रैल 2023
प्रोजेक्ट स्थिति
सक्रिय

मूल README

यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।

html_character_entities

A Dart utility class containing maps of key/value pairs for every HTML 4.01 character entity, including ASCII and hex codes, and methods to encode and decode strings to and from those character entities.

Usage

import 'package:html_character_entities/html_character_entities.dart';

Decoding Strings

The decode method accepts a string as an argument and returns it after replacing every character entity with their corresponding characters.

String string = 'An ampersand can be written as & and &.';

print(HtmlCharacterEntities.decode(string)); // An ampersand can be written as & and &.

Encoding Strings

The encode() method has an argument, [characters], that accepts a string of all characters that should be encoded. It defaults to the 5 reserved characters in both HTML and XML: less-than (<), greater-than (>), ampersand (&), apostrophe or single quote ('), and double-quote (").

String string = '<, >, &, \', and " aren\'t safe to use in HTML and XML.';

print(HtmlCharacterEntities.encode(string));
// &lt;, &gt;, &amp;, &apos;, and &quot; aren&apos;t safe to use in HTML and XML.

print(HtmlCharacterEntities.encode(string, characters: 'XHTML'));
// <, >, &, ', and " aren't safe to use in &#72;&#84;&#77;&#76; and &#88;&#77;&#76;.

If [characters] is null, every character in the HtmlCharacterEntities.characters map will be encoded.

Maps

A map of every HTML 4.01 character code, as well as their ASCII and hex code entities can be referenced from HtmlCharacterEntities.characters.

Note: The hex codes in the map don't have leading 0s. I.e. the hex code &#x0000a5; is in the map as &#xa5;. When decoding hex code entities, the leading 0s will be removed by the parser before being looked up.

Map<String, String> c = HtmlCharacterEntities.characters;

String string = 'There are 4 suites of cards: ${c['&spades;']} Spades, ${c['&clubs;']} Clubs, ${c['&hearts;']} Hearts, ${c['&diams;']} Diamonds';

print(string); // There are 4 suites of cards: ♠ Spades, ♣ Clubs, ♥ Hearts, ♦ Diamonds

Maps containing the characters with their respective character codes as values can also be referenced. They are used by the encode method.

// A map with only ASCII code character entities as values.
Map<String, String> ascii = HtmlCharacterEntities.asciiCodes;

// A map with all non-ASCII code character entities as values.
Map<String, String> entity = HtmlCharacterEntities.entities;

String string = '< and > exist as both ASCII codes (${ascii['<']} and ${ascii['>']}) and character entities (${entity['<']} and ${entity['>']}).';

print(string); // < and > exist as both ASCII codes (&#60; and &#62;) and character entities (&lt; and &gt;).
James GitHub avatar
GitHub लेखक

James ↗

भाषाएँDart

इस रिपॉज़िटरी के पैकेज

उपयोग की गई निर्भरताएँ

निर्भरता सूची 2 आइटम

  • pedanticडेवलपमेंट^1.11.0
  • testडेवलपमेंट^1.16.5

अपने प्रोजेक्ट के लिए रिपॉज़िटरी कैसे चुनें?

उपयोग के अनुसार छाँटें, गतिविधि की तुलना करें और अपनाने से पहले मूल प्रोजेक्ट की आवश्यकताएँ जाँचें।

  1. नाम, लेखक या विवरण से खोजें और तकनीकी विषय से परिणाम सीमित करें।
  2. स्टार, फ़ोर्क और हाल के पुश की तुलना करें। स्टार रुचि दर्शाते हैं, गुणवत्ता की गारंटी नहीं।
  3. उपयोग से पहले GitHub पर README, लाइसेंस और Issues जाँचें।

स्रोत और रखरखाव

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗