公开文本搜索urdu&英语 [英] open text search urdu & English

查看:63
本文介绍了公开文本搜索urdu&英语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Option Strict Off
Option Explicit On
Friend Class Form1
	Inherits System.Windows.Forms.Form
	Dim counter As Short
	Dim search As Object
	Dim se As String
	'UPGRADE_WARNING: Event C.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
    
    Private Sub l_DoubleClick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtRead.DoubleClick
        MsgBox(txtRead.Text)
    End Sub

    Private Sub txtWrite_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtWrite.TextChanged
        
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        txtRead.Items.Clear()
        txtcount.Text = CStr(0)
        If Len(txtWrite.Text) <> 0 Then
            se = txtWrite.Text
            txtcount.Text = CStr(0)
            FileOpen(1, "C:\search.txt", OpenMode.Input)
            While Not EOF(1)
                txtcount.Text = CStr(CDbl(txtcount.Text) + 1)
                Input(1, search)
                For counter = 1 To Len(search)
                    
                    If Mid(se, 1, Len(txtWrite.Text)) = Mid(search, counter, Len(txtWrite.Text)) Then
                        txtRead.Items.Add((search))

                    End If
                Next
            End While
            FileClose(1)
        End If
        txtcount.Text = txtRead.Items.Count & "/" & txtcount.Text
    End Sub
End Class


我在调试文件夹"city name.txt"中有1个文本文件


I have 1 text file in debug folder "city name.txt"

lahore        لاہور
gujrat        گجرات
shaikhupura       شیخوپورہ
hadraabad         حیدرآباد
ect


我的项目名称搜索城市名称.vbvb.net 2005
1个文本框txtCsearch
2个文本框txtNameCity
文本框1键按下事件
文本框2打开搜索结果

英语单词是开放的,但未打开乌尔都语单词.
乌尔都语单词该怎么做?

请帮帮我
zaka


My Project name search city name.vb vb.net 2005
1 textbox txtCsearch
2 textbox txtNameCity
textbox 1 key press event
textbox 2 open search Result

English words are open, but Urdu Words are not opened.
Urdu words to search for what to do?

Please help me
zaka

推荐答案

除非您松散Unicode信息,否则语言,乌尔都语或英语绝对没有区别.您的输入文件应使用Unicode UTF之一进行编码.

避免使用CStr.这是一个传统的强制转换运算符.您永远不需要它.而是使用object.ToString.您完全不需要此任务.

您的代码很难理解,但是搜索非常简单.

确保您正确阅读了文本文件.对于文本文件,请使用System.IO.StreamReader,请参见:
http://msdn.microsoft.com/zh-我们/library/system.io.streamreader%28v=vs.100%29.aspx [ http://msdn.microsoft.com/en-us/library/9y86s1a9.aspx [ ^ ].

如果您知道某些文件中不存在BOM表,但您知道编码,则可以显式传递编码.在这种情况下,请使用以下命令:
http://msdn.microsoft.com/en-us/library/x8xxf0x5.aspx [ ^ ].

使用System.IO.StreamReader.ReadLine逐行读取文件,或使用ReadToEnd读取整个文件.必要时使用其他读取方法.

使用System.String.IndexOf方法在字符串中搜索子字符串:
http://msdn.microsoft.com/en-us/library/system.string.aspx [ ^ ].

通常,停止使用旧版VB素材.使用.NET!

另外,您需要了解Unicode的主要思想.请参阅:
http://unicode.org/ [ ^ ],
http://unicode.org/faq/utf_bom.html [
There is absolutely no difference what is the language, Urdu or English unless you loose Unicode information. Your input file should use one of Unicode UTFs for encoding.

Avoid using CStr. This is a legacy cast operator. You never need it. Instead, use object.ToString. You don''t need it for this task at all.

Your code is hard to understand, but the search is really simple.

Make sure you read text file correctly. For text files, use System.IO.StreamReader, see:
http://msdn.microsoft.com/en-us/library/system.io.streamreader%28v=vs.100%29.aspx[^].

In most cases, you need to open text files, ASCII and Unicode, using encoding detection based on BOM (see below). ASCII files do not contain BOM, which is also detected correctly. Use this constructor with second parameter set to true:
http://msdn.microsoft.com/en-us/library/9y86s1a9.aspx[^].

If you know that in some files BOM is not present but you know the encoding, you can pass encoding explicitly. In this case, use this:
http://msdn.microsoft.com/en-us/library/x8xxf0x5.aspx[^].

Read the file line by line using System.IO.StreamReader.ReadLine or read the whole file using ReadToEnd. Use other read methods when required.

Search for substring in a string using System.String.IndexOf methods:
http://msdn.microsoft.com/en-us/library/system.string.aspx[^].

In general, stop using legacy VB stuff. Use .NET!

Also, you need to understand main ideas of Unicode. Please see:
http://unicode.org/[^],
http://unicode.org/faq/utf_bom.html[^].

—SA


这篇关于公开文本搜索urdu&amp;英语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆