예제 #1
0
        // Constructor: Construct from both Unicode and NonUnicode data, according to fUnicode
        /// <devdoc>
        ///    <para>
        ///       Initializes a new instance of the <see cref='System.Data.SqlTypes.SqlString'/> class.
        ///    </para>
        /// </devdoc>
        public SqlString(int lcid, SqlCompareOptions compareOptions, byte[] data, int index, int count, bool fUnicode)
        {
            _lcid = lcid;
            ValidateSqlCompareOptions(compareOptions);
            _flag = compareOptions;
            if (data == null)
            {
                _fNotNull = false;
                _value    = null;
                _cmpInfo  = null;
            }
            else
            {
                _fNotNull = true;

                // m_cmpInfo is set lazily, so that we don't need to pay the cost
                // unless the string is used in comparison.
                _cmpInfo = null;

                if (fUnicode)
                {
                    _value = x_UnicodeEncoding.GetString(data, index, count);
                }
                else
                {
                    Encoding cpe = LocaleInterop.GetEncodingForLcid(_lcid);
                    _value = cpe.GetString(data, index, count);
                }
            }
        }
예제 #2
0
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public byte[] GetNonUnicodeBytes()
        {
            if (IsNull)
            {
                return(null);
            }

            // Get the CultureInfo
            Encoding cpe = LocaleInterop.GetEncodingForLcid(_lcid);

            return(cpe.GetBytes(_value));
        }