Node.js  v8.x
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine
node_i18n.h
Go to the documentation of this file.
1 // Copyright Joyent, Inc. and other Node contributors.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to permit
8 // persons to whom the Software is furnished to do so, subject to the
9 // following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 
22 #ifndef SRC_NODE_I18N_H_
23 #define SRC_NODE_I18N_H_
24 
25 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26 
27 #include "node.h"
28 #include <string>
29 
30 #if defined(NODE_HAVE_I18N_SUPPORT)
31 
32 namespace node {
33 
34 extern std::string icu_data_dir; // NOLINT(runtime/string)
35 
36 namespace i18n {
37 
38 bool InitializeICUDirectory(const std::string& path);
39 
40 enum idna_mode {
41  // Default mode for maximum compatibility.
42  IDNA_DEFAULT,
43  // Ignore all errors in IDNA conversion, if possible.
44  IDNA_LENIENT,
45  // Enforce STD3 rules (UseSTD3ASCIIRules) and DNS length restrictions
46  // (VerifyDnsLength). Corresponds to `beStrict` flag in the "domain to ASCII"
47  // algorithm.
48  IDNA_STRICT
49 };
50 
51 // Implements the WHATWG URL Standard "domain to ASCII" algorithm.
52 // https://url.spec.whatwg.org/#concept-domain-to-ascii
53 int32_t ToASCII(MaybeStackBuffer<char>* buf,
54  const char* input,
55  size_t length,
56  enum idna_mode mode = IDNA_DEFAULT);
57 
58 // Implements the WHATWG URL Standard "domain to Unicode" algorithm.
59 // https://url.spec.whatwg.org/#concept-domain-to-unicode
60 int32_t ToUnicode(MaybeStackBuffer<char>* buf,
61  const char* input,
62  size_t length);
63 
64 } // namespace i18n
65 } // namespace node
66 
67 #endif // NODE_HAVE_I18N_SUPPORT
68 
69 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
70 
71 #endif // SRC_NODE_I18N_H_
unsigned char * buf
Definition: cares_wrap.cc:483