forked from nolanw/HTMLReader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHTMLEncoding.h
More file actions
40 lines (30 loc) · 1.77 KB
/
HTMLEncoding.h
File metadata and controls
40 lines (30 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// HTMLEncoding.h
//
// Public domain. https://github.com/nolanw/HTMLReader
#import <Foundation/Foundation.h>
/// Tags a string encoding with a confidence that the parser can use to help determine how to decode bytes into a document.
typedef struct {
NSStringEncoding encoding;
enum {
Tentative,
Certain,
Irrelevant
} confidence;
} HTMLStringEncoding;
/**
Returns a string encoding that likely encodes the data.
@param contentType The value of the HTTP Content-Type header, if present.
For more information, see https://html.spec.whatwg.org/multipage/syntax.html#determining-the-character-encoding
*/
extern HTMLStringEncoding DeterminedStringEncodingForData(NSData *data, NSString *contentType);
/// Returns the string encoding labeled according to the WHATWG Encoding Standard. Returns InvalidStringEncoding() if the label is unknown.
extern NSStringEncoding StringEncodingForLabel(NSString *label);
/// An invalid NSStringEncoding. Equal to CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingInvalidId).
extern NSStringEncoding InvalidStringEncoding(void);
/**
Returns YES if encoding "is a single-byte or variable-length encoding in which the bytes 0x09, 0x0A, 0x0C, 0x0D, 0x20 - 0x22, 0x26, 0x27, 0x2C - 0x3F, 0x41 - 0x5A, and 0x61 - 0x7A, ignoring bytes that are the second and later bytes of multibyte sequences, all correspond to single-byte sequences that map to the same Unicode characters as those bytes in Windows-1252".
For more information, see https://html.spec.whatwg.org/multipage/infrastructure.html#ascii-compatible-character-encoding
*/
extern BOOL IsASCIICompatibleEncoding(NSStringEncoding encoding);
/// Returns YES if encoding is UTF16-LE or UTF16-BE.
extern BOOL IsUTF16Encoding(NSStringEncoding encoding);