Hi All,
I want to validate a string, and see if it contains any Chinese character
(simple or traditional). I'm trying to use RegExp and Encoding, but no
result.
Can someone point me a direction?
Kind regards,
Kevin 2 5174
Hi Kevin,
I am not sure why you would need the Encoding class. All strings are
internally Unicode in .NET (unless you are dealing with _byte_ arrays).
Therefore, what I think you need first is to determine what range(s) of
numeric character codes constitute all the Chinese hieroglyphs. Then, just
define an RegExp pattern that would capture all such characters, for
example, if there are just two ranges:
[\uXXXX-\uYYYY]|[\uZZZZ-\uWWWW]
(of course XXXX must be numerically less than YYYY, the same goes for ZZZZ
and WWWW).
--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"Kevin" <ke***@home.n l> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. Hi All,
I want to validate a string, and see if it contains any Chinese character (simple or traditional). I'm trying to use RegExp and Encoding, but no result. Can someone point me a direction?
Kind regards, Kevin
Kevin <ke***@home.n l> wrote: I want to validate a string, and see if it contains any Chinese character (simple or traditional). I'm trying to use RegExp and Encoding, but no result. Can someone point me a direction?
Dmytro gave a regular expression solution - I'd just hard code it,
personally. Just iterate through each character in the string, and
check whether it's in the range you're interested in. Personally I
think that's a bit more readable than the regular expression solution,
although if there are lots of ranges to consider, a regular expression
formatted on multiple lines with a range and a comment on each line
might be better than a hard-coded solution. (The hard-coded solution is
likely to be faster too, but I wouldn't worry about that until you've
determined that it's actually a performance bottleneck.)
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: michaelpyles |
last post by:
I have the following URL that was HTML encoded in my web page:
<a HREF="transfer/rad0/﨨.jpg" TARGET="_blank">﨨.jpg</a>
I am attempting to download this file which is simply one chinese character followed by .jpg. For IE, Netscape, Safari I right click on this URL and attempt to download the file. If the name contains only ASCII characters it works. I also cannot cut and paste this URL directly into IE and retrieve my image either. What...
|
by: lungwahchong |
last post by:
Hi,
I have these strings which are pulled from a database which contains both
english and chinese characters(big5).
e.g.
Fragrant Rice 10kg Green Dragon????
Broken Rice 10kg G.Elephant ?????
|
by: mikeyjudkins |
last post by:
I have an XML file containing localized strings in 9 languages, encoded
in Unicode (UTF-8). Im trying to parse this XML document via XSLT
(Apache Xalan) to selectively render localized strings depending on a
users selected language.
The problem Im running into is that when the XML document is sent
through the XSLT stylesheet, all European special characters (such as
umlauts, accents, etc) are converted to html character entities (as...
|
by: Zhang Weiwu |
last post by:
Hello. I am working with a php software project, in it
(www.egroupware.org) Chinese simplified locate is "zh" while Traditional
Chinese "tw".
I wish to send correct language attribute in http header, I found "zh"
is not standard. I found this line in apache2's default httpd.conf
# Simplified Chinese (zh-CN)
AddLanguage zh-CN .zh-cn
|
by: accessyou |
last post by:
I am using a windows 2000 with apache and php5
A simple url submit containing only english characters are OK:
http://www.abc.com/submit.php?msg=test
If the value of msg is replaced with a chinese:
http://www.abc.com/submit.php?msg=中文
| |
by: James P. |
last post by:
Hello there,
In my asp.net page using VB, I have a date text field in mm/dd/yyyy
format. When a date is entered, I'd like to validate it to make sure
the date is greater than or equal to the current date. If not, I'd
like to display the error message to ValidationSummary.
It seems to make sense to me to use CompareValidator but the problem
is put the current date into CompareValidator. So, I created a hidden
text field in my aspx. ...
|
by: c676228 |
last post by:
Hi everyone,
I just realized that it's so important to validate each string, I mean
'each' before you insert data from asp page into database.
I guess some customers just copy data from some electronic document and
paste into
form field which it will probably mess up the program.
for example, we have a customer who wants to enter AH12345 into one of our
fields, it appears АН12345 in hidden field of our asp page, but it displayed...
|
by: Lord0 |
last post by:
I *think* I need to be able to validate subsets of an XML document
using different schema. The functionality I'm trying to implement is
this.
a) External suppliers produce an XML document containing multiple User
records. The external supplier validates this entire document using
schema 1. This document is then uploaded to our system.
b) Our system then checks that the supplied document "looks okay",
minimally, using Schema 2. Schema...
|
by: lookon |
last post by:
I have a string a(for example, a='Chinese'), and I want to know
whether there are some Chinese in the string.
Can someone tell me how to do it? Thanks!
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |