comparison xml/en/docs/njs/reference.xml @ 2982:02889d1bab78

Marked byte string methods as removed in njs Reference.
author Yaroslav Zhuravlev <yar@nginx.com>
date Thu, 01 Jun 2023 17:12:18 +0100
parents 576e06abd683
children 67dd348c9757
comparison
equal deleted inserted replaced
2981:576e06abd683 2982:02889d1bab78
7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> 7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd">
8 8
9 <article name="Reference" 9 <article name="Reference"
10 link="/en/docs/njs/reference.html" 10 link="/en/docs/njs/reference.html"
11 lang="en" 11 lang="en"
12 rev="105"> 12 rev="106">
13 13
14 <section id="summary"> 14 <section id="summary">
15 15
16 <para> 16 <para>
17 <link doc="index.xml">njs</link> provides objects, methods and properties 17 <link doc="index.xml">njs</link> provides objects, methods and properties
2809 2809
2810 2810
2811 <section id="string" name="String"> 2811 <section id="string" name="String">
2812 2812
2813 <para> 2813 <para>
2814 There are two types of strings in njs: a Unicode string (default) and 2814 By default all strings in njs are Unicode strings.
2815 a byte string. 2815 They correspond to ECMAScript strings that contain Unicode characters.
2816 </para> 2816 Before <link doc="changes.xml" id="njs0.8.0">0.8.0</link>,
2817 2817 byte strings were also supported.
2818 <para> 2818 </para>
2819 A Unicode string corresponds to an ECMAScript string 2819
2820 which contains Unicode characters. 2820 <section id="byte_string" name="Byte strings">
2821
2822 <para>
2823 <note>
2824 Since <link doc="changes.xml" id="njs0.8.0">0.8.0</link>,
2825 the support for byte strings and byte string methods were removed.
2826 When working with byte sequence,
2827 the <link id="buffer">Buffer</link> object
2828 and <literal>Buffer</literal> properties, such as
2829 <link id="r_request_buffer"><literal>r.requestBuffer</literal></link>,
2830 <link id="r_raw_variables"><literal>r.rawVariables</literal></link>,
2831 should be used.
2832 </note>
2821 </para> 2833 </para>
2822 2834
2823 <para> 2835 <para>
2824 Byte strings contain a sequence of bytes 2836 Byte strings contain a sequence of bytes
2825 and are used to serialize Unicode strings 2837 and are used to serialize Unicode strings
2841 <list type="tag"> 2853 <list type="tag">
2842 2854
2843 <tag-name id="string_bytesfrom"><literal>String.bytesFrom(<value>array</value> 2855 <tag-name id="string_bytesfrom"><literal>String.bytesFrom(<value>array</value>
2844 | <value>string</value>, <value>encoding</value>)</literal></tag-name> 2856 | <value>string</value>, <value>encoding</value>)</literal></tag-name>
2845 <tag-desc> 2857 <tag-desc>
2846 Creates a byte string either from an array that contains octets, 2858 The method was made obsolete in
2859 <link doc="changes.xml" id="njs0.4.4">0.4.4</link>
2860 and was removed in <link doc="changes.xml" id="njs0.8.0">0.8.0</link>.
2861 The <literal>Buffer.from</literal> method should be used instead:
2862 <example>
2863 >> Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]).toString()
2864 'buffer'
2865
2866 >> Buffer.from('YnVmZmVy', 'base64').toString()
2867 'buffer'
2868 </example>
2869 Before <link doc="changes.xml" id="njs0.4.4">0.4.4</link>,
2870 created a byte string either from an array that contained octets,
2847 or from an encoded string 2871 or from an encoded string
2848 (<link doc="changes.xml" id="njs0.2.3">0.2.3</link>). 2872 (<link doc="changes.xml" id="njs0.2.3">0.2.3</link>),
2849 The encoding can be 2873 the encoding could be
2850 <literal>hex</literal>, 2874 <literal>hex</literal>,
2851 <literal>base64</literal>, and 2875 <literal>base64</literal>, and
2852 <literal>base64url</literal>. 2876 <literal>base64url</literal>.
2853 The method is deprecated since
2854 <link doc="changes.xml" id="njs0.4.4">0.4.4</link>,
2855 the <literal>Buffer.from</literal> method should be used instead:
2856 <example>
2857 >> Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]).toString()
2858 'buffer'
2859
2860 >> Buffer.from('YnVmZmVy', 'base64').toString()
2861 'buffer'
2862 </example>
2863 </tag-desc> 2877 </tag-desc>
2864 2878
2865 <tag-name id="string_frombytes"><literal>String.prototype.fromBytes(<value>start</value>[, 2879 <tag-name id="string_frombytes"><literal>String.prototype.fromBytes(<value>start</value>[,
2866 <value>end</value>])</literal></tag-name> 2880 <value>end</value>])</literal></tag-name>
2867 <tag-desc> 2881 <tag-desc>
2868 the property is deprecated since 2882 the property was made obsolete in
2869 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>. 2883 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>
2884 and was removed in <link doc="changes.xml" id="njs0.8.0">0.8.0</link>.
2870 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, 2885 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>,
2871 returned a new Unicode string from a byte string 2886 returned a new Unicode string from a byte string
2872 where each byte was replaced with a corresponding Unicode code point. 2887 where each byte was replaced with a corresponding Unicode code point.
2873 </tag-desc> 2888 </tag-desc>
2874 2889
2875 <tag-name id="string_fromutf8"><literal>String.prototype.fromUTF8(<value>start</value>[, 2890 <tag-name id="string_fromutf8"><literal>String.prototype.fromUTF8(<value>start</value>[,
2876 <value>end</value>])</literal></tag-name> 2891 <value>end</value>])</literal></tag-name>
2877 <tag-desc> 2892 <tag-desc>
2878 the property is deprecated since 2893 the property was made obsolete in
2879 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, 2894 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>
2880 the <link id="textedeoder"><literal>TextDecoder</literal></link> method 2895 and was removed in <link doc="changes.xml" id="njs0.8.0">0.8.0</link>.
2896 The <link id="textedeoder"><literal>TextDecoder</literal></link> method
2881 should be used instead. 2897 should be used instead.
2882 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, 2898 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>,
2883 converted a byte string containing a valid UTF-8 string 2899 converted a byte string containing a valid UTF-8 string
2884 into a Unicode string, 2900 into a Unicode string,
2885 otherwise <literal>null</literal> was returned. 2901 otherwise <literal>null</literal> was returned.
2886 </tag-desc> 2902 </tag-desc>
2887 2903
2888 <tag-name id="string_tobytes"><literal>String.prototype.toBytes(<value>start</value>[, 2904 <tag-name id="string_tobytes"><literal>String.prototype.toBytes(<value>start</value>[,
2889 <value>end</value>])</literal></tag-name> 2905 <value>end</value>])</literal></tag-name>
2890 <tag-desc> 2906 <tag-desc>
2891 the property is deprecated since 2907 the property was made obsolete in
2892 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>. 2908 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>
2909 and was removed in <link doc="changes.xml" id="njs0.8.0">0.8.0</link>.
2893 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, 2910 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>,
2894 serialized a Unicode string to a byte string, 2911 serialized a Unicode string to a byte string,
2895 returned <literal>null</literal> if a character larger than 255 was 2912 returned <literal>null</literal> if a character larger than 255 was
2896 found in the string. 2913 found in the string.
2897 </tag-desc> 2914 </tag-desc>
2898 2915
2899 <tag-name id="string_tostring"><literal>String.prototype.toString(<value>encoding</value>)</literal></tag-name> 2916 <tag-name id="string_tostring"><literal>String.prototype.toString(<value>encoding</value>)</literal></tag-name>
2900 <tag-desc> 2917 <tag-desc>
2901 <para> 2918 <para>
2902 the property is deprecated since 2919 the property was made obsolete in
2903 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>. 2920 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>
2921 and was removed in <link doc="changes.xml" id="njs0.8.0">0.8.0</link>.
2904 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, 2922 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>,
2905 encoded a string to 2923 encoded a string to
2906 <literal>hex</literal>, 2924 <literal>hex</literal>,
2907 <literal>base64</literal>, or 2925 <literal>base64</literal>, or
2908 <literal>base64url</literal>: 2926 <literal>base64url</literal>:
2920 </tag-desc> 2938 </tag-desc>
2921 2939
2922 <tag-name id="string_toutf8"><literal>String.prototype.toUTF8(<value>start</value>[, 2940 <tag-name id="string_toutf8"><literal>String.prototype.toUTF8(<value>start</value>[,
2923 <value>end</value>])</literal></tag-name> 2941 <value>end</value>])</literal></tag-name>
2924 <tag-desc> 2942 <tag-desc>
2925 the property is deprecated since 2943 the property was made obsolete in
2926 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, 2944 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>
2927 the <link id="textencoder"><literal>TextEncoder</literal></link> method 2945 and was removed in <link doc="changes.xml" id="njs0.8.0">0.8.0</link>.
2946 The <link id="textencoder"><literal>TextEncoder</literal></link> method
2928 should be used instead. 2947 should be used instead.
2929 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, 2948 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>,
2930 serialized a Unicode string 2949 serialized a Unicode string
2931 to a byte string using UTF-8 encoding: 2950 to a byte string using UTF-8 encoding:
2932 <example> 2951 <example>
2937 </example> 2956 </example>
2938 </tag-desc> 2957 </tag-desc>
2939 2958
2940 </list> 2959 </list>
2941 </para> 2960 </para>
2961
2962 </section>
2942 2963
2943 </section> 2964 </section>
2944 2965
2945 </section> 2966 </section>
2946 2967