Exemplo n.º 1
0
        private Console()
        {
            ReadLock  = new Object();
            WriteLock = new Object();
            String csname = encoding();

            if (csname != null)
            {
                try
                {
                    Cs = Charset.ForName(csname);
                }
                catch (Exception)
                {
                }
            }
            if (Cs == null)
            {
                Cs = Charset.DefaultCharset();
            }
            @out           = StreamEncoder.forOutputStreamWriter(new FileOutputStream(FileDescriptor.@out), WriteLock, Cs);
            Pw             = new PrintWriterAnonymousInnerClassHelper(this, @out);
            Formatter      = new Formatter(@out);
            Reader_Renamed = new LineReader(this, StreamDecoder.forInputStreamReader(new FileInputStream(FileDescriptor.@in), ReadLock, Cs));
            Rcb            = new char[1024];
        }
Exemplo n.º 2
0
        private static void verifyPayment(Payment payment)
        {
            string     resultString = "".ToString();
            JSONObject jsonObject   = new JSONObject();

            jsonObject.Put("payload", payment.Payload);

            string verifystring = (string)jsonObject;
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Content-Type", "application/json; charset=UTF-8");
            headers.Add(merchantApiHeaderKeyForApiSecretKey, merchantApiSecretKey);
            //
            AsyncHttpClient.Post(merchantServerUrl + VERIFY, headers, verifystring, new HttpResponseCallback
            {
                Success = (response) =>
                {
                    Java.Lang.String mString      = new Java.Lang.String(response, Charset.ForName("UTF-8"));
                    JSONObject jsonVerifyResponse = new JSONObject((string)mString);
                    Java.Lang.String authResponse = new Java.Lang.String(jsonVerifyResponse.GetString("authResponse"));
                    if (authResponse.EqualsIgnoreCase(payment.GetPaymentStatus().ToString()))
                    {
                        resultString = "Payment is " + payment.GetPaymentStatus().ToString().ToLower() + " and verified.";
                    }
                    else
                    {
                        resultString = "Failed to verify payment.";
                    }
                },
                Failure = (th) =>
                {
                    Toast.MakeText(context, resultString, ToastLength.Long).Show();
                }
            });
        }
Exemplo n.º 3
0
        private Boolean FormatNFC(Ndef ndef)
        {
            bool retorno = false;

            NdefFormatable ndefFormatable = NdefFormatable.Get(ndef.Tag);

            Java.Lang.String msg = new Java.Lang.String(MENSAGEM_PADRAO);
            try
            {
                if (ndefFormatable == null)
                {
                    return(retorno);
                }

                if (!ndefFormatable.IsConnected)
                {
                    ndefFormatable.Connect();
                }
                ndefFormatable.Format(new NdefMessage(NdefRecord.CreateMime
                                                          ("UTF-8", msg.GetBytes(Charset.ForName("UTF-8")))));
                ndefFormatable.Close();
                retorno = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw new System.Exception("Não foi possível ler o cartão.");
            }

            return(retorno);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public UTF32Encoding(bool bigEndian, bool byteOrderMark, bool throwOnInvalidBytes)
     : base(Charset.ForName(GetCharsetName(bigEndian, byteOrderMark)))
 {
     this.bigEndian           = bigEndian;
     this.byteOrderMark       = byteOrderMark;
     this.throwOnInvalidBytes = throwOnInvalidBytes;
 }
Exemplo n.º 5
0
        public System.String EncodeToNonLossyAscii(System.String original)
        {
            Charset asciiCharset = Charset.ForName("US-ASCII");

            if (asciiCharset.NewEncoder().CanEncode(original))
            {
                return(original);
            }
            StringBuffer stringBuffer = new StringBuffer();

            for (int i = 0; i < original.Length; i++)
            {
                char c = original.ElementAt(i);
                if (c < 128)
                {
                    stringBuffer.Append(c.ToString());
                }
                else if (c < 256)
                {
                    System.String octal = Integer.ToOctalString(c);
                    stringBuffer.Append("\\");
                    stringBuffer.Append(octal);
                }
                else
                {
                    System.String hex = Integer.ToHexString(c);
                    stringBuffer.Append("\\u");
                    stringBuffer.Append(hex);
                }
            }
            return(stringBuffer.ToString());
        }
Exemplo n.º 6
0
        private bool WriteNFC(Ndef ndef, string mensagem)
        {
            bool retorno = false;

            try
            {
                if (ndef != null)
                {
                    ndef.Connect();
                    NdefRecord mimeRecord = null;

                    Java.Lang.String str = new Java.Lang.String(mensagem);

                    mimeRecord = NdefRecord.CreateMime
                                     ("UTF-8", str.GetBytes(Charset.ForName("UTF-8")));

                    ndef.WriteNdefMessage(new NdefMessage(mimeRecord));
                    ndef.Close();
                    retorno = true;
                }
                else
                {
                    retorno = FormatNFC(ndef);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw new System.Exception("Não foi possível ler o cartão.");
            }

            return(retorno);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Returns a charset object for the given charset name. </summary>
        /// <exception cref="NullPointerException">          is csn is null </exception>
        /// <exception cref="UnsupportedEncodingException">  if the charset is not supported </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static java.nio.charset.Charset toCharset(String csn) throws UnsupportedEncodingException
        private static Charset ToCharset(String csn)
        {
            Objects.RequireNonNull(csn, "charsetName");
            try
            {
                return(Charset.ForName(csn));
            }
//JAVA TO C# CONVERTER TODO TASK: There is no equivalent in C# to Java 'multi-catch' syntax:
            catch (IllegalCharsetNameException | UnsupportedCharsetException unused)
            {
                // UnsupportedEncodingException should be thrown
                throw new UnsupportedEncodingException(csn);
            }
        }
Exemplo n.º 8
0
 private static Charset LookupCharset(String csn)
 {
     if (Charset.IsSupported(csn))
     {
         try
         {
             return(Charset.ForName(csn));
         }
         catch (UnsupportedCharsetException x)
         {
             throw new Error(x);
         }
     }
     return(null);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Return the header string for a set of XML formatted records.
        /// </summary>
        /// <param name="h">  The target handler (can be null) </param>
        /// <returns>  a valid XML string </returns>
        public override String GetHead(Handler h)
        {
            StringBuilder sb = new StringBuilder();
            String        encoding;

            sb.Append("<?xml version=\"1.0\"");

            if (h != null)
            {
                encoding = h.Encoding;
            }
            else
            {
                encoding = null;
            }

            if (encoding == null)
            {
                // Figure out the default encoding.
                encoding = Charset.DefaultCharset().Name();
            }
            // Try to map the encoding name to a canonical name.
            try
            {
                Charset cs = Charset.ForName(encoding);
                encoding = cs.Name();
            }
            catch (Exception)
            {
                // We hit problems finding a canonical name.
                // Just use the raw encoding name.
            }

            sb.Append(" encoding=\"");
            sb.Append(encoding);
            sb.Append("\"");
            sb.Append(" standalone=\"no\"?>\n");
            sb.Append("<!DOCTYPE log SYSTEM \"logger.dtd\">\n");
            sb.Append("<log>\n");
            return(sb.ToString());
        }
        /**
         *
         * Método faz a gravação de uma nova mensagem no cartão.
         *
         * Essa nova mensagem será códificada usando o padrão UTF-8.
         *
         * @param ndef = Contém as informações do cartão que esta sendo lido.
         * @param mensagem = Mensagem que será gravada no cartão
         *
         * @throws IOException
         * @throws FormatException
         *
         * @return boolean =>  True = Mensagem Gravada / False = Erro ao gravar mensagem
         *
         * */
        public bool GavarMensagemCartao(Ndef ndef, string mensagem)
        {
            bool retorno = false;

            try
            {
                if (ndef != null)
                {
                    ndef.Connect();
                    NdefRecord mimeRecord = null;

                    Java.Lang.String str = new Java.Lang.String(mensagem);

                    mimeRecord = NdefRecord.CreateMime
                                     ("UTF-8", str.GetBytes(Charset.ForName("UTF-8")));

                    ndef.WriteNdefMessage(new NdefMessage(mimeRecord));
                    ndef.Close();
                    retorno = true;
                }
                else
                {
                    retorno = FormataCartao(ndef);
                }
            }
            catch (System.FormatException e)
            {
                throw new System.FormatException(e.Message);
            }
            catch (IOException e)
            {
                throw new IOException(e.Message);
            }
            finally
            {
                this.GravaTempoFinal();
            }

            return(retorno);
        }
        /**
         *
         * Método faz a formatação do cartão.
         *
         * A formatação do cartão só é necessario na sua primeira gravação.
         *
         * Após já existir algum valor gravado no cartão, não será possível formata-lo
         * novamente.
         *
         * @param ndef = Contém as informações do cartão que esta sendo lido.
         *
         * @throws IOException
         * @throws FormatException
         *
         * @return boolean =>  True = Cartão Formatado / False = Cartão não formatado
         *
         * */
        public bool FormataCartao(Ndef ndef)
        {
            bool retorno = false;

            NdefFormatable ndefFormatable = NdefFormatable.Get(ndef.Tag);

            Java.Lang.String msg = new Java.Lang.String(MENSAGEM_PADRAO);
            try
            {
                if (ndefFormatable == null)
                {
                    return(retorno);
                }

                if (!ndefFormatable.IsConnected)
                {
                    ndefFormatable.Connect();
                }
                ndefFormatable.Format(new NdefMessage(NdefRecord.CreateMime
                                                          ("UTF-8", msg.GetBytes(Charset.ForName("UTF-8")))));
                ndefFormatable.Close();
                retorno = true;
            }
            catch (IOException e)
            {
                throw new IOException(e.Message);
            }
            catch (System.FormatException e)
            {
                throw new System.FormatException(e.Message);
            }
            finally
            {
                this.GravaTempoFinal();
            }


            return(retorno);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public UTF8Encoding()
     : base(Charset.ForName("UTF-8"))
 {
     byteOrderMark = false;
 }
Exemplo n.º 13
0
        private void SetScanner()
        {
            // Scanner default settings
            BarcodeScannerSettings_ settings = mBarcodeScanner.Settings;

            // Trigger Mode
            settings.Scan.TriggerMode = ScanSettings_.TriggerMode_.AutoOff;
            //settings.Scan.TriggerMode = ScanSettings_.TriggerMode_.Momentary;
            //settings.Scan.TriggerMode = ScanSettings_.TriggerMode_.Alternate;
            //settings.Scan.TriggerMode = ScanSettings_.TriggerMode_.Continuous;
            //settings.Scan.TriggerMode = ScanSettings_.TriggerMode_.TriggerRelease;

            // For 2D Module Settings
            if (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d)
            {
                // Light Mode
                settings.Scan.LightMode = ScanSettings_.LightMode_.Auto;
                //settings.Scan.LightMode = ScanSettings_.LightMode_.AlwaysOn;
                //settings.Scan.LightMode = ScanSettings_.LightMode_.Off;

                //Marker Mode
                settings.Scan.MarkerMode = ScanSettings_.MarkerMode_.Normal;
                //settings.Scan.MarkerMode = ScanSettings_.MarkerMode_.Ahead;
                //settings.Scan.MarkerMode = ScanSettings_.MarkerMode_.Off;
            }

            // For 2D LONG Module Settings
            if (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2dLong)
            {
                settings.Scan.SideLightMode = ScanSettings_.SideLightMode_.Off;
                //settings.Scan.SideLightMode = ScanSettings_.SideLightMode_.On;
            }

            // Notification Sound Settings
            settings.Notification.Sound.Enabled = true;
            //settings.Notification.Sound.Enabled = false;

            if (settings.Notification.Sound.Enabled)
            {
                settings.Notification.Sound.UsageType = NotificationSettings_.UsageType_.Ringtone;
                //settings.Notification.Sound.UsageType = NotificationSettings_.UsageType_.Media;
                //settings.Notification.Sound.UsageType = NotificationSettings_.UsageType_.Alarm;

                if (settings.Notification.Sound.UsageType == NotificationSettings_.UsageType_.Media)
                {
                    //TO BE Implement
                    settings.Notification.Sound.GoodDecodeFilePath = "";
                }
            }

            //Notification Vibrator
            //settings.Notification.Vibrate.Enabled = false;
            settings.Notification.Vibrate.Enabled = true;


            // Decode Settings

            // Decode interval
            settings.Decode.SameBarcodeIntervalTime = 200; // 1,000msec

            // For 1D & 2D Module Settings
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type1d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d))
            {
                // Decode Level
                settings.Decode.DecodeLevel = 4;              // Decode Level
            }

            // Invert Mode
            settings.Decode.InvertMode = DecodeSettings_.InvertMode_.Disabled;
            //settings.Decode.InvertMode = DecodeSettings_.InvertMode_.InversionOnly;
            //settings.Decode.InvertMode = DecodeSettings_.InvertMode_.Auto;

            // For 2D & 2D LONG Module Settings
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2dLong))
            {
                // Point Scan Mode
                settings.Decode.PointScanMode = DecodeSettings_.PointScanMode_.Disabled;
                //settings.Decode.PointScanMode = DecodeSettings_.PointScanMode_.Enabled;
            }

            // For 2D Module Settings
            if (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d)
            {
                // Reverse Mode
                settings.Decode.ReverseMode = DecodeSettings_.ReverseMode_.Disabled;
                //settings.Decode.ReverseMode = DecodeSettings_.ReverseMode_.Enabled;
            }

            // Encode Charset
            settings.Decode.Charset = Charset.ForName("Shift-JIS");
            //settings.Decode.Charset = Charset.ForName("UTF-8");


            // Symbology Settings

            // For 2D Module Settings
            if (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d)
            {
                // Multi Line
                settings.Decode.MultiLineMode.Enabled = false;
            }

            //JAN-13(EAN-13), UPC-A
            settings.Decode.Symbologies.Ean13UpcA.Enabled = true;
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type1d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d))
            {
                settings.Decode.Symbologies.Ean13UpcA.FirstCharacter  = "";
                settings.Decode.Symbologies.Ean13UpcA.SecondCharacter = "";
            }
            settings.Editing.Ean13.ReportCheckDigit = true;
            settings.Editing.UpcA.ReportCheckDigit  = true;
            settings.Editing.UpcA.AddLeadingZero    = true;

            // EAN-13 add on
            settings.Decode.Symbologies.Ean13UpcA.AddOn.Enabled       = false;
            settings.Decode.Symbologies.Ean13UpcA.AddOn.OnlyWithAddOn = false;
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type1d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d))
            {
                settings.Decode.Symbologies.Ean13UpcA.AddOn.AddOn2Digit = false;
                settings.Decode.Symbologies.Ean13UpcA.AddOn.AddOn5Digit = false;
            }

            // JAN-8(EAN-8)
            settings.Decode.Symbologies.Ean8.Enabled = true;
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type1d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d))
            {
                settings.Decode.Symbologies.Ean8.FirstCharacter  = "";
                settings.Decode.Symbologies.Ean8.SecondCharacter = "";
            }
            settings.Editing.Ean8.ReportCheckDigit = true;

            // EAN-8 add on
            settings.Decode.Symbologies.Ean8.AddOn.Enabled       = false;
            settings.Decode.Symbologies.Ean8.AddOn.OnlyWithAddOn = false;
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type1d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d))
            {
                settings.Decode.Symbologies.Ean8.AddOn.AddOn2Digit = false;
                settings.Decode.Symbologies.Ean8.AddOn.AddOn5Digit = false;
            }

            // UPC-E
            settings.Decode.Symbologies.UpcE.Enabled = true;
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type1d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d))
            {
                settings.Decode.Symbologies.UpcE.FirstCharacter  = "";
                settings.Decode.Symbologies.UpcE.SecondCharacter = "";
            }
            settings.Editing.UpcE.ReportCheckDigit = true;
            settings.Editing.UpcE.AddLeadingZero   = false;
            settings.Editing.UpcE.ConvertToUpcA    = false;
            settings.Editing.UpcE.ReportNumberSystemCharacterOfConvertedUpcA = true;

            // UPC-E add on
            settings.Decode.Symbologies.UpcE.AddOn.Enabled       = false;
            settings.Decode.Symbologies.UpcE.AddOn.OnlyWithAddOn = false;
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type1d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d))
            {
                settings.Decode.Symbologies.UpcE.AddOn.AddOn2Digit = false;
                settings.Decode.Symbologies.UpcE.AddOn.AddOn5Digit = false;
            }

            // ITF
            settings.Decode.Symbologies.Itf.Enabled          = true;
            settings.Decode.Symbologies.Itf.LengthMin        = 4;
            settings.Decode.Symbologies.Itf.LengthMax        = 99;
            settings.Decode.Symbologies.Itf.VerifyCheckDigit = false;
            //settings.Decode.Symbologies.itf.verifyCheckDigit = true;
            settings.Editing.Itf.ReportCheckDigit = true;

            // STF
            settings.Decode.Symbologies.Stf.Enabled          = true;
            settings.Decode.Symbologies.Stf.LengthMin        = 4;
            settings.Decode.Symbologies.Stf.LengthMax        = 99;
            settings.Decode.Symbologies.Stf.VerifyCheckDigit = false;
            //settings.Decode.Symbologies.stf.verifyCheckDigit = true;
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type1d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2dLong))
            {
                settings.Decode.Symbologies.Stf.StartStopCharacter = "";
                //settings.Decode.Symbologies.Stf.StartStopCharacter = "S";
                //settings.Decode.Symbologies.Stf.StartStopCharacter = "N";
            }
            settings.Editing.Stf.ReportCheckDigit = true;

            // Codabar
            settings.Decode.Symbologies.Codabar.Enabled          = true;
            settings.Decode.Symbologies.Codabar.LengthMin        = 4;
            settings.Decode.Symbologies.Codabar.LengthMax        = 99;
            settings.Decode.Symbologies.Codabar.VerifyCheckDigit = false;
            //settings.Decode.Symbologies.Codabar.VerifyCheckDigit = true;
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type1d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d))
            {
                settings.Decode.Symbologies.Codabar.StartStopCharacter = "";
            }
            settings.Editing.Codabar.ReportCheckDigit         = true;
            settings.Editing.Codabar.ReportStartStopCharacter = true;
            settings.Editing.Codabar.ConvertToUpperCase       = false;

            // Code39
            settings.Decode.Symbologies.Code39.Enabled          = true;
            settings.Decode.Symbologies.Code39.LengthMin        = 1;
            settings.Decode.Symbologies.Code39.LengthMax        = 99;
            settings.Decode.Symbologies.Code39.VerifyCheckDigit = false;
            //settings.Decode.Symbologies.Code39.VerifyCheckDigit = true;
            settings.Editing.Code39.ReportCheckDigit         = true;
            settings.Editing.Code39.ReportStartStopCharacter = false;

            // Code93
            settings.Decode.Symbologies.Code93.Enabled   = true;
            settings.Decode.Symbologies.Code93.LengthMin = 1;
            settings.Decode.Symbologies.Code93.LengthMax = 99;

            // Code128
            settings.Decode.Symbologies.Code128.Enabled   = true;
            settings.Decode.Symbologies.Code128.LengthMin = 1;
            settings.Decode.Symbologies.Code128.LengthMax = 99;

            // MSI
            if (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type1d)
            {
                settings.Decode.Symbologies.Msi.Enabled   = true;
                settings.Decode.Symbologies.Msi.LengthMin = 1;
                settings.Decode.Symbologies.Msi.LengthMax = 99;
                settings.Decode.Symbologies.Msi.NumberOfCheckDigitVerification = 1;
                //settings.Decode.Symbologies.Msi.NumberOfCheckDigitVerification = 2;
            }

            // GS1 Databar
            settings.Decode.Symbologies.Gs1DataBar.Enabled = true;
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type1d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d))
            {
                settings.Decode.Symbologies.Gs1DataBar.Stacked = false;
            }

            // Gs1 Databar Limited
            settings.Decode.Symbologies.Gs1DataBarLimited.Enabled = false;

            // Gs1 Databar Expanded
            settings.Decode.Symbologies.Gs1DataBarExpanded.Enabled   = false;
            settings.Decode.Symbologies.Gs1DataBarExpanded.LengthMin = 1;
            settings.Decode.Symbologies.Gs1DataBarExpanded.LengthMax = 99;
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type1d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d))
            {
                settings.Decode.Symbologies.Gs1DataBarExpanded.Stacked = false;
            }

            // Gs1 Composite
            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2dLong))
            {
                settings.Decode.Symbologies.Gs1Composite.Enabled = false;
            }

            if ((mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d) ||
                (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2dLong))
            {
                // QR Code
                settings.Decode.Symbologies.QrCode.Enabled = false;

                if (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d)
                {
                    settings.Decode.Symbologies.QrCode.SplitMode = Symbologies_.SplitModeQr_.Disabled;
                    //settings.Decode.Symbologies.QrCode.SplitMode = Symbologies_.SplitModeQr_.Edit;
                    //settings.Decode.Symbologies.QrCode.SplitMode = Symbologies_.SplitModeQr_.BatchEdit;
                    //settings.Decode.Symbologies.QrCode.SplitMode = Symbologies_.SplitModeQr_.NonEdit;

                    // QR Code Model1
                    settings.Decode.Symbologies.QrCode.Model1.Enabled    = true;
                    settings.Decode.Symbologies.QrCode.Model1.VersionMin = 1;
                    settings.Decode.Symbologies.QrCode.Model1.VersionMax = 22;

                    // QR Code Model2
                    settings.Decode.Symbologies.QrCode.Model2.Enabled    = true;
                    settings.Decode.Symbologies.QrCode.Model2.VersionMin = 1;
                    settings.Decode.Symbologies.QrCode.Model2.VersionMax = 40;

                    // Micro QR Code
                    settings.Decode.Symbologies.MicroQr.Enabled    = true;
                    settings.Decode.Symbologies.MicroQr.VersionMin = 1;
                    settings.Decode.Symbologies.MicroQr.VersionMax = 4;

                    // iQR Code
                    settings.Decode.Symbologies.IqrCode.Enabled   = true;
                    settings.Decode.Symbologies.IqrCode.SplitMode = Symbologies_.SplitModeIqr_.Disabled;
                    //settings.Decode.Symbologies.IqrCode.SplitMode = Symbologies_.SplitModeIqr_.Edit;
                    //settings.Decode.Symbologies.IqrCode.SplitMode = Symbologies_.SplitModeIqr_.NonEdit;

                    // Square iQR Code
                    settings.Decode.Symbologies.IqrCode.Square.Enabled    = true;
                    settings.Decode.Symbologies.IqrCode.Square.VersionMin = 1;
                    settings.Decode.Symbologies.IqrCode.Square.VersionMax = 61;

                    // Rectangle iQR Code
                    settings.Decode.Symbologies.IqrCode.Rectangle.Enabled    = true;
                    settings.Decode.Symbologies.IqrCode.Rectangle.VersionMin = 1;
                    settings.Decode.Symbologies.IqrCode.Rectangle.VersionMax = 15;
                }
                else
                {
                    //For 2D Long model
                    settings.Decode.Symbologies.MicroQr.Enabled = false;
                    settings.Decode.Symbologies.IqrCode.Enabled = false;
                }

                // Data Matrix
                settings.Decode.Symbologies.DataMatrix.Enabled = true;

                if (mScannerType == BarcodeScannerInfo_.BarcodeScannerType_.Type2d)
                {
                    // DataMatrix Square
                    settings.Decode.Symbologies.DataMatrix.Square.Enabled       = true;
                    settings.Decode.Symbologies.DataMatrix.Square.CodeNumberMin = 1;
                    settings.Decode.Symbologies.DataMatrix.Square.CodeNumberMax = 24;

                    // DataMatrix ReactAngle
                    settings.Decode.Symbologies.DataMatrix.Rectangle.Enabled       = true;
                    settings.Decode.Symbologies.DataMatrix.Rectangle.CodeNumberMin = 1;
                    settings.Decode.Symbologies.DataMatrix.Rectangle.CodeNumberMax = 6;
                }

                // PDF417
                settings.Decode.Symbologies.Pdf417.Enabled = true;

                // Micro PDF 417
                settings.Decode.Symbologies.MicroPdf417.Enabled = true;

                // Maxi
                settings.Decode.Symbologies.MaxiCode.Enabled = true;
            }
            else
            {
                //For 1D model
                settings.Decode.Symbologies.QrCode.Enabled      = false;
                settings.Decode.Symbologies.MicroQr.Enabled     = false;
                settings.Decode.Symbologies.IqrCode.Enabled     = false;
                settings.Decode.Symbologies.Pdf417.Enabled      = false;
                settings.Decode.Symbologies.MicroPdf417.Enabled = false;
                settings.Decode.Symbologies.MaxiCode.Enabled    = false;
                settings.Decode.Symbologies.DataMatrix.Enabled  = false;
            }

            mBarcodeScanner.Settings = settings;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Translates a string into {@code application/x-www-form-urlencoded}
        /// format using a specific encoding scheme. This method uses the
        /// supplied encoding scheme to obtain the bytes for unsafe
        /// characters.
        /// <para>
        /// <em><strong>Note:</strong> The <a href=
        /// "http://www.w3.org/TR/html40/appendix/notes.html#non-ascii-chars">
        /// World Wide Web Consortium Recommendation</a> states that
        /// UTF-8 should be used. Not doing so may introduce
        /// incompatibilities.</em>
        ///
        /// </para>
        /// </summary>
        /// <param name="s">   {@code String} to be translated. </param>
        /// <param name="enc">   The name of a supported
        ///    <a href="../lang/package-summary.html#charenc">character
        ///    encoding</a>. </param>
        /// <returns>  the translated {@code String}. </returns>
        /// <exception cref="UnsupportedEncodingException">
        ///             If the named encoding is not supported </exception>
        /// <seealso cref= URLDecoder#decode(java.lang.String, java.lang.String)
        /// @since 1.4 </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static String encode(String s, String enc) throws java.io.UnsupportedEncodingException
        public static String Encode(String s, String enc)
        {
            bool            needToChange = false;
            StringBuffer    @out         = new StringBuffer(s.Length());
            Charset         charset;
            CharArrayWriter charArrayWriter = new CharArrayWriter();

            if (enc == null)
            {
                throw new NullPointerException("charsetName");
            }

            try
            {
                charset = Charset.ForName(enc);
            }
            catch (IllegalCharsetNameException)
            {
                throw new UnsupportedEncodingException(enc);
            }
            catch (UnsupportedCharsetException)
            {
                throw new UnsupportedEncodingException(enc);
            }

            for (int i = 0; i < s.Length();)
            {
                int c = (int)s.CharAt(i);
                //System.out.println("Examining character: " + c);
                if (DontNeedEncoding.Get(c))
                {
                    if (c == ' ')
                    {
                        c            = '+';
                        needToChange = true;
                    }
                    //System.out.println("Storing: " + c);
                    @out.Append((char)c);
                    i++;
                }
                else
                {
                    // convert to external encoding before hex conversion
                    do
                    {
                        charArrayWriter.Write(c);

                        /*
                         * If this character represents the start of a Unicode
                         * surrogate pair, then pass in two characters. It's not
                         * clear what should be done if a bytes reserved in the
                         * surrogate pairs range occurs outside of a legal
                         * surrogate pair. For now, just treat it as if it were
                         * any other character.
                         */
                        if (c >= 0xD800 && c <= 0xDBFF)
                        {
                            /*
                             * System.out.println(Integer.toHexString(c)
                             + " is high surrogate");
                             */
                            if ((i + 1) < s.Length())
                            {
                                int d = (int)s.CharAt(i + 1);

                                /*
                                 * System.out.println("\tExamining "
                                 + Integer.toHexString(d));
                                 */
                                if (d >= 0xDC00 && d <= 0xDFFF)
                                {
                                    /*
                                     * System.out.println("\t"
                                     + Integer.toHexString(d)
                                     + " is low surrogate");
                                     */
                                    charArrayWriter.Write(d);
                                    i++;
                                }
                            }
                        }
                        i++;
                    } while (i < s.Length() && !DontNeedEncoding.Get((c = (int)s.CharAt(i))));

                    charArrayWriter.Flush();
                    String  str = new String(charArrayWriter.ToCharArray());
                    sbyte[] ba  = str.GetBytes(charset);
                    for (int j = 0; j < ba.Length; j++)
                    {
                        @out.Append('%');
                        char ch = Character.ForDigit((ba[j] >> 4) & 0xF, 16);
                        // converting to use uppercase letter as part of
                        // the hex value if ch is a letter.
                        if (char.IsLetter(ch))
                        {
                            ch -= CaseDiff;
                        }
                        @out.Append(ch);
                        ch = Character.ForDigit(ba[j] & 0xF, 16);
                        if (char.IsLetter(ch))
                        {
                            ch -= CaseDiff;
                        }
                        @out.Append(ch);
                    }
                    charArrayWriter.Reset();
                    needToChange = true;
                }
            }

            return(needToChange? @out.ToString() : s);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public ASCIIEncoding()
     : base(Charset.ForName("US-ASCII"))
 {
 }
Exemplo n.º 16
0
 /// <summary>
 /// Default ctor
 /// </summary>
 /// <param name="bigEndian">If true, use big endian encoding: MSB first, otherwise little endian: LSB first.</param>
 /// <param name="byteOrderMark">If true, provide a byte order mark, false otherwise</param>
 public UnicodeEncoding(bool bigEndian, bool byteOrderMark)
     : base(Charset.ForName(GetCharsetName(bigEndian, byteOrderMark)))
 {
     this.bigEndian     = bigEndian;
     this.byteOrderMark = byteOrderMark;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Constructs a writer that encodes characters according to the named
 /// charset and writes the resulting bytes to the given channel.
 ///
 /// <para> An invocation of this method of the form
 ///
 /// <blockquote><pre>
 /// Channels.newWriter(ch, csname)</pre></blockquote>
 ///
 /// behaves in exactly the same way as the expression
 ///
 /// <blockquote><pre>
 /// Channels.newWriter(ch,
 ///                    Charset.forName(csName)
 ///                        .newEncoder(),
 ///                    -1);</pre></blockquote>
 ///
 /// </para>
 /// </summary>
 /// <param name="ch">
 ///         The channel to which bytes will be written
 /// </param>
 /// <param name="csName">
 ///         The name of the charset to be used
 /// </param>
 /// <returns>  A new writer
 /// </returns>
 /// <exception cref="UnsupportedCharsetException">
 ///          If no support for the named charset is available
 ///          in this instance of the Java virtual machine </exception>
 public static Writer NewWriter(WritableByteChannel ch, String csName)
 {
     CheckNotNull(csName, "csName");
     return(NewWriter(ch, Charset.ForName(csName).NewEncoder(), -1));
 }
Exemplo n.º 18
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public UTF8Encoding(bool byteOrderMark)
     : base(Charset.ForName("UTF-8"))
 {
     this.byteOrderMark = byteOrderMark;
 }
Exemplo n.º 19
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public UTF8Encoding(bool byteOrderMark, bool throwOnInvalidBytes)
     : base(Charset.ForName("UTF-8"))
 {
     this.byteOrderMark       = byteOrderMark;
     this.throwOnInvalidBytes = throwOnInvalidBytes;
 }
Exemplo n.º 20
0
        private void verifyPayment(Payment payment)
        {
            JSONObject jsonObject = new JSONObject();

            try
            {
                jsonObject.Put("payload", payment.Payload);
            }
            catch (JSONException e)
            {
                Toast.MakeText(this, "Failed to verify payment.", ToastLength.Long).Show();
                return;
            }
            String verifyString = jsonObject.ToString();

            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Content-Type", "application/json; charset=UTF-8");
            headers.Add(merchantApiHeaderKeyForApiSecretKey, merchantApiSecretKey);
            String resultString = "";


            AsyncHttpClient.Post(merchantServerUrl + VERIFY, headers, verifyString, new HttpResponseCallback
            {
                Success = (response) =>
                {
                    try
                    {
                        JSONObject jsonVerifyResponse = new JSONObject((string)new Java.Lang.String(response, Charset.ForName("UTF-8")));
                        String authResponse           = jsonVerifyResponse.GetString("authResponse");
                        if (authResponse.Equals(payment.GetPaymentStatus().ToString()))
                        {
                            resultString = "Payment is " + payment.GetPaymentStatus().ToString().ToLower() + " and verified.";
                        }
                        else
                        {
                            resultString = "Failed to verify payment.";
                        }
                    }
                    catch (JSONException e)
                    {
                        resultString = "Failed to verify payment.";
                    }
                    Toast.MakeText(this, resultString, ToastLength.Long).Show();
                },

                Failure = (e) =>
                {
                    Toast.MakeText(this, resultString, ToastLength.Long).Show();
                }
            });
        }
Exemplo n.º 21
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public UnicodeEncoding()
     : base(Charset.ForName("UTF-16LE"))
 {
     bigEndian     = false;
     byteOrderMark = false;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Constructs a reader that decodes bytes from the given channel according
 /// to the named charset.
 ///
 /// <para> An invocation of this method of the form
 ///
 /// <blockquote><pre>
 /// Channels.newReader(ch, csname)</pre></blockquote>
 ///
 /// behaves in exactly the same way as the expression
 ///
 /// <blockquote><pre>
 /// Channels.newReader(ch,
 ///                    Charset.forName(csName)
 ///                        .newDecoder(),
 ///                    -1);</pre></blockquote>
 ///
 /// </para>
 /// </summary>
 /// <param name="ch">
 ///         The channel from which bytes will be read
 /// </param>
 /// <param name="csName">
 ///         The name of the charset to be used
 /// </param>
 /// <returns>  A new reader
 /// </returns>
 /// <exception cref="UnsupportedCharsetException">
 ///          If no support for the named charset is available
 ///          in this instance of the Java virtual machine </exception>
 public static Reader NewReader(ReadableByteChannel ch, String csName)
 {
     CheckNotNull(csName, "csName");
     return(NewReader(ch, Charset.ForName(csName).NewDecoder(), -1));
 }