Ejemplo n.º 1
0
        private void comboBoxCodePage_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxCodePage.SelectedIndex >= 0)
            {
                CodePageIndex = comboBoxCodePage.SelectedIndex;
                if (_previewBuffer != null)
                {
                    Encoding      encoding     = Pac.GetEncoding(CodePageIndex);
                    int           FEIndex      = 0;
                    int           endDelimiter = 0x00;
                    StringBuilder sb           = new StringBuilder();
                    int           index        = FEIndex + 3;
                    while (index < _previewBuffer.Length && _previewBuffer[index] != endDelimiter)
                    {
                        if (_previewBuffer[index] == 0xFE)
                        {
                            sb.AppendLine();
                            index += 2;
                        }
                        else if (_previewBuffer[index] == 0xFF)
                        {
                            sb.Append(" ");
                        }
                        else if (CodePageIndex == 0)
                        {
                            sb.Append(Pac.GetLatinString(encoding, _previewBuffer, ref index));
                        }
                        else if (CodePageIndex == 3)
                        {
                            sb.Append(Pac.GetArabicString(_previewBuffer, ref index));
                        }
                        else if (CodePageIndex == 4)
                        {
                            sb.Append(Pac.GetHebrewString(_previewBuffer, ref index));
                        }
                        else if (CodePageIndex == 6)
                        {
                            sb.Append(Pac.GetCyrillicString(_previewBuffer, ref index));
                        }
                        else
                        {
                            sb.Append(encoding.GetString(_previewBuffer, index, 1));
                        }

                        index++;
                    }
                    if (CodePageIndex == 3)
                    {
                        textBoxPreview.Text = Utilities.FixEnglishTextInRightToLeftLanguage(sb.ToString(), "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
                    }
                    else
                    {
                        textBoxPreview.Text = sb.ToString();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void comboBoxCodePage_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxCodePage.SelectedIndex >= 0)
            {
                CodePageIndex = comboBoxCodePage.SelectedIndex;
                if (_previewBuffer != null)
                {
                    Encoding  encoding     = Pac.GetEncoding(CodePageIndex);
                    const int feIndex      = 0;
                    const int endDelimiter = 0x00;
                    var       sb           = new StringBuilder();
                    int       index        = feIndex + 3;
                    while (index < _previewBuffer.Length && _previewBuffer[index] != endDelimiter)
                    {
                        if (_previewBuffer[index] == 0xFE)
                        {
                            sb.AppendLine();
                            index += 2;
                        }
                        else if (_previewBuffer[index] == 0xFF)
                        {
                            sb.Append(' ');
                        }
                        else if (CodePageIndex == Pac.CodePageLatin)
                        {
                            sb.Append(Pac.GetLatinString(encoding, _previewBuffer, ref index));
                        }
                        else if (CodePageIndex == Pac.CodePageArabic)
                        {
                            sb.Append(Pac.GetArabicString(_previewBuffer, ref index));
                        }
                        else if (CodePageIndex == Pac.CodePageHebrew)
                        {
                            sb.Append(Pac.GetHebrewString(_previewBuffer, ref index));
                        }
                        else if (CodePageIndex == Pac.CodePageCyrillic)
                        {
                            sb.Append(Pac.GetCyrillicString(_previewBuffer, ref index));
                        }
                        else
                        {
                            sb.Append(encoding.GetString(_previewBuffer, index, 1));
                        }

                        index++;
                    }
                    if (CodePageIndex == Pac.CodePageArabic)
                    {
                        textBoxPreview.Text = Utilities.FixEnglishTextInRightToLeftLanguage(sb.ToString(), PreviewChars);
                    }
                    else
                    {
                        textBoxPreview.Text = sb.ToString();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void comboBoxCodePage_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxCodePage.SelectedIndex >= 0)
            {
                CodePageIndex = comboBoxCodePage.SelectedIndex;
                if (_previewBuffer != null)
                {
                    var       encoding     = Pac.GetEncoding(CodePageIndex);
                    const int feIndex      = 0;
                    const int endDelimiter = 0x00;
                    int       index;

                    var indexOfW16 = Encoding.ASCII.GetString(_previewBuffer).IndexOf("W16", StringComparison.Ordinal);
                    if (indexOfW16 > 0 && indexOfW16 < _previewBuffer.Length - 5)
                    {
                        index = indexOfW16 + 4;
                        if (CodePageIndex == Pac.CodePageChineseSimplified)
                        {
                            textBoxPreview.Text = Encoding.GetEncoding(Pac.EncodingChineseSimplified).GetString(_previewBuffer, index, _previewBuffer.Length - index);
                            return;
                        }

                        if (CodePageIndex == Pac.CodePageChineseTraditional)
                        {
                            textBoxPreview.Text = Encoding.GetEncoding(Pac.EncodingChineseTraditional).GetString(_previewBuffer, index, _previewBuffer.Length - index);
                            return;
                        }

                        if (CodePageIndex == Pac.CodePageKorean)
                        {
                            textBoxPreview.Text = Encoding.GetEncoding(Pac.EncodingKorean).GetString(_previewBuffer, index, _previewBuffer.Length - index);
                            return;
                        }

                        if (CodePageIndex == Pac.CodePageJapanese)
                        {
                            textBoxPreview.Text = Encoding.GetEncoding(Pac.EncodingJapanese).GetString(_previewBuffer, index, _previewBuffer.Length - index);
                            return;
                        }
                    }

                    var sb = new StringBuilder();
                    index = feIndex + 3;
                    while (index < _previewBuffer.Length && _previewBuffer[index] != endDelimiter)
                    {
                        if (_previewBuffer[index] == 0xFE)
                        {
                            sb.AppendLine();
                            index += 2;
                        }
                        else if (_previewBuffer[index] == 0xFF)
                        {
                            sb.Append(' ');
                        }
                        else if (CodePageIndex == Pac.CodePageLatin)
                        {
                            sb.Append(Pac.GetLatinString(encoding, _previewBuffer, ref index));
                        }
                        else if (CodePageIndex == Pac.CodePageArabic)
                        {
                            sb.Append(Pac.GetArabicString(_previewBuffer, ref index));
                        }
                        else if (CodePageIndex == Pac.CodePageHebrew)
                        {
                            sb.Append(Pac.GetHebrewString(_previewBuffer, ref index));
                        }
                        else if (CodePageIndex == Pac.CodePageCyrillic)
                        {
                            sb.Append(Pac.GetCyrillicString(_previewBuffer, ref index));
                        }
                        else if (CodePageIndex == Pac.CodePageGreek)
                        {
                            sb.Append(Pac.GetGreekString(_previewBuffer, ref index));
                        }
                        else
                        {
                            sb.Append(encoding.GetString(_previewBuffer, index, 1));
                        }

                        index++;
                    }

                    if (CodePageIndex == Pac.CodePageArabic)
                    {
                        textBoxPreview.Text = Utilities.FixEnglishTextInRightToLeftLanguage(sb.ToString(), PreviewChars);
                    }
                    else
                    {
                        textBoxPreview.Text = sb.ToString();
                    }
                }
            }
        }