Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static byte[] encode(String charsetName, char[] ca, int off, int len) throws java.io.UnsupportedEncodingException
        internal static sbyte[] Encode(String charsetName, char[] ca, int off, int len)
        {
            StringEncoder se  = Deref(Encoder);
            String        csn = (charsetName == null) ? "ISO-8859-1" : charsetName;

            if ((se == null) || !(csn.Equals(se.RequestedCharsetName()) || csn.Equals(se.CharsetName())))
            {
                se = null;
                try
                {
                    Charset cs = LookupCharset(csn);
                    if (cs != null)
                    {
                        se = new StringEncoder(cs, csn);
                    }
                }
                catch (IllegalCharsetNameException)
                {
                }
                if (se == null)
                {
                    throw new UnsupportedEncodingException(csn);
                }
                Set(Encoder, se);
            }
            return(se.Encode(ca, off, len));
        }