|
Hello everybody,
I need a method in c# to transform non english word to a unique string representation. The method should detect if the word contains non english characters and, only in that case it converts the word to diffrent representation, the algo is the following:
String transformString(String inputString)
{
if(inputString.containsNonEnglishChar())
{
String res = "";
foreach(char ch in inputString)
{
res += transformChar(ch);
}
return res;
}
return inputString;
}
I can write the method my way, but I prefer to find something standard, like base 64 or URL encoding or something famous.
Thanks in advance.
HZ
|
|
|
|
|
The System.Char structure [^] has some properties like IsLetter .
Probably there are similar functions that are culture aware, for which you basically pass some English culture (e.g. "en-US") and then call "IsLetter " and get a true /false if it is or not.
|
|
|
|
|
Thanks man,
I can know if a char is in the ASCII range,
I can do this: if((int)ch <= 255), and this is sufficient in my case, but I try to find a better way to encode the string like the url format. As Does the HttpServerUtility.UrlEncode method.
But I cannot add a reference to the System.web namespace, I have to find some alternative.
Thanks for your advice.
HZ
|
|
|
|
|
HZ_79 wrote: I cannot add a reference to the System.web namespace
Why is it so?
just do: Solution Pane/Add Reference/.NET/System.Web
then insert a using statement.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
One possibility to encode all non-ASCII characters is to use UTF-7[^]:
encode: Encoding.ASCII.GetString(Encoding.UTF7.GetBytes(text))
decode: Encoding.UTF7.GetString(Encoding.ASCII.GetBytes(encodedString))
modified on Wednesday, June 3, 2009 10:55 AM
|
|
|
|
|
I am using vs2003, i want to edit, delete , create some entries in registry thru coding, i read some article here & on others sites too. And doing this fine.
But if i make some changes in registry, then i have to restart pc for them to take effects.
a) Is there any way to update/Reload registry, without restarting pc?
b) Also, How to Reload whole window OS without restart?
any link, help would be appreciated.
regards.
|
|
|
|
|
You don't "reload the Registry". You have to notify or reload the component that uses those registry values to get it to see the changes, IF that component exposes such functionality. If not, you have no choice but to restart the system for those changes to take effect.
What changes are you making??
|
|
|
|
|
Dave Kreskowiak wrote: What changes are you making??
I am deleting some registry entries used by an application.
But even if the entries got deleted the application keeps on running until it restarts.
So, Isn't there a way to do this thru coding?
(like when we install some application then upon complete installation, the whole explorer(all open windows) got refreshed, i think it reloading os/reg)
Dave Kreskowiak wrote: You have to notify or reload the component that uses those registry values to get it to see the changes,
How can i notify an application to check or reload itself?
regards
|
|
|
|
|
Hum Dum wrote: So, Isn't there a way to do this thru coding?
(like when we install some application then upon complete installation, the whole explorer(all open windows) got
The O/S and/or Explorer and/or the registry does NOT get reloaded right before the users eyes.
Hum Dum wrote: How can i notify an application to check or reload itself?
The notification method, if any, depends on what needs to be notified. For example, changing the background image is a broadcast message to Explorer sent using a specific API in Windows. But, this method ONLY works if the app (Explorer) is listening for it. It will NOT work with other applications.
Hum Dum wrote: I am deleting some registry entries used by an application.
But even if the entries got deleted the application keeps on running until it restarts.
This is true. Most applications will not see any changes you make to their registry settings until the app is restarted. Most applications will, also, NOT expose any method to tell them that they need to reload their registry settings. Your best (read: most reliable) course of action is to stop the app and restart it.
|
|
|
|
|
If the changes are to a part that Explorer uses then just killing the Explorer process works as well, but please don't
Better inform the user that the changes will only apply after rebooting and letting him do it himself..
|
|
|
|
|
harold aptroot wrote: just killing the Explorer process
I tried to do this, but it only works in xp, vista OS.
On windows 2000 its not working, screen simply got blank if i kill the explorer ,
Any other help would be appreciated.
regards
|
|
|
|
|
Ok well it's a very bad thing to do anyway.. Standard practice is to ask whether to reboot now or later.
|
|
|
|
|
Hi,
In my application there is three ports listening, each have corresponding AsyncCallback method, ie 3 AsyncCallback method in the application. These three AsyncCallback methods are working as thread.These are ready to accept messages at any time.
How can i block or wait first and second AsyncCallback method while the third AsyncCallback methord is executing.
So after the execution of the third AsyncCallback method, next message in the queue is ready to execute, it can be in first , second or third AsyncCallback method.
Yhankyou
YPKI
|
|
|
|
|
|
|
hello experts
I have scanner thr' which i am scanning barcode.I want to do coding for same.when device trigger clicked,textbox must show respective barcode no.
Give me any useful link or code for same.
|
|
|
|
|
Barcode scanners generally come with an API, or mimic keyboard entry depending on the make/model. There is no way whatsoever for anyone to answer your question without knowing which type of scanner you are using.
KIDYA wrote: Give me any useful link or code for same.
Even if you had worded that sentence politely (ie, with the addition of the word please) nobody is going to help you unless you help yourself.
|
|
|
|
|
Then what is my work? i m new wid this.is there any operations want to do wid API? or it will installed automatically when set up of scanner install.
|
|
|
|
|
That sentence makes no sense. "wid" is not a word in the English language (Although freakishly enough its my wife's pet name for her dad dont ask!)
|
|
|
|
|
Apparently, wid is the new with. Just like his name is the new word for fail.
|
|
|
|
|
Set the focus to your text box and pull the trigger.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: pull the trigger.
stick'em up
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
hi,
I want to ask how to convert this C struct into C#.net
typedef struct _MT_EVENT {
#if _WIN32
LARGE_INTEGER TimeStamp; // In FILETIME format
#elif LINUX
struct timeval TimeStamp; // In gettimeofday() format
#endif
ULONG UserStatus; // Not used by API
ULONG EventCode; // Event Code
ULONG SubReason; // Event sub-reason
ULONG XtraInfo; // Extra information, e.g. termination
ULONG FuncCode; // Function active when this event occurred
USHORT Board; // Board ID
USHORT Channel; // Global Channel ID (GCI)
PVOID ptrBuffer; // Related play/record buffer pointer
ULONG DataLength; // Byte length of data accessed (played/recorded)
PVOID ptrXtraBuffer; // Pointer to xtra buffer
ULONG XtraBufferLength; // Length of buffer pointed by ptrXtraBuffer
ULONG XtraDataLength; // Length of data in buffer pointed by ptrXtraBuffer
ULONG EventFlag; // Falgs of the following:
// bit 0x00000001: 1 - Appl created the event
// 0 - NTi DLL created the event
// bit 0x00000002: 1 - Appl allocated ptrtraBuffer
// 0 - NTi DLL allocated ptrXtraBuffer
} MT_EVENT, *PMT_EVENT;
|
|
|
|
|
Check out the code MS provides for the Windows Mobile Gps, http://msdn.microsoft.com/en-us/library/ms881362.aspx[^] (Sample code comes with the SDK)
It contains many C structs written in C#, fairly cool. (Although, the sample like all MS samples doesn't work out of the box)
|
|
|
|
|
I'm not so hot on all that interop stuff and its a guess, but you could try this:
[StructLayout(LayoutKind.Sequential)]
public struct _MT_EVENT
{
public long TimeStamp;
public ulong UserStatus;
public ulong EventCode;
public ulong SubReason;
public ulong XtraInfo;
public ulong FuncCode;
public ushort Board;
public ushort Channel;
public IntPtr ptrBuffer;
public ulong DataLength;
public IntPtr ptrXtraBuffer;
public ulong XtraBufferLength;
public ulong XtraDataLength;
public ulong EventFlag;
}
Regards,
Rob Philpott.
|
|
|
|