|
Ever heard of GOOGLE
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Yea as a matter of fact I have read 17 articles before posting and about 25 since posting. I guess I'm just not as good at understanding it as you are!
rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Rafone wrote: I have read 17 articles before posting and about 25 since posting
Absolutely pathetic. In all of your searching you couldn't even find this: Implementing Finalize and Dispose[^]
Hell even here the first five of 140,000 hits show exact code to implement it.
Disposal Pattern .NET[^]
You will never get any where in this field by feigning such ignorance and having others do the work for you.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Yes found and read both of those you sight. As I said before finding articles to read is not the problem understanding them is....
I guess if you understood then you would have been helping me to understand instead of pointing me in the direction I had already taken.
thanks for your time though...
rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Rafone wrote: I guess if you understood then you would have been helping me
The links present you with clear, concise and full implementations of this pattern. Perhaps you should state clearly what part of it you don't understand rather than down voting.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
It appears this is a bug in VS2010
I am seeing a CA200 Warning (call Dispose) on a variable declared within a using statement.
Type: Bug
ID: 521027
Opened: 12/17/2009 2:10:58 PM
Access Restriction: Public
0 Workaround(s)
7 User(s) can reproduce this bug
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
First you can't understand the code, now you think it is a bug. Do you understand the code now?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
It was the warning I was trying to understand....After searching and reading post after post I did find that error report on Microsoft Connect.
I thought becase the Form was disposing all components including the hosted toolstrip (that I provided code for) that it was being disposed. According to the bug report that warning can be generated erronously with VS2010.
I'm not sure why you are so persistant in making be feel that my knowledge is so lacking. I know that I am not an expert. I don't do this as a profession I do it like some people do crossword puzzles to relax a little bit. I am a miner by profession.
I'm sorry if I have offended any and all readers of this forum but I though this is where I could ask questions of experts to help my simplistic knowledge of C# expand.
Again thanks for the time you have spent and I apoligize to you and the group for not being on the same level as you guys.
rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Rafone wrote: It was the warning I was trying to understand
In your first post you said, "I'm not sure where to place the System.IDisposable.Dispose". You give no mention or indication in any subsequent post that it is the warning you don't understand.
Again you posted, "based on the error text I gathered that this is what I am supposed to do. If I knew how I wouldn't have had to ask...". Once again this implies you are having difficulty with implementation of the Disposal Pattern code, not the original error message.
Rafone wrote: I though this is where I could ask questions of experts to help my simplistic knowledge of C# expand.
It is. However, you have the responsibility to clear and accurately state your question and intentions. We don't read minds and are not working in the same room with you on the same project on the same piece of code. You can't assume we will know implicitly what you mean or are referring to. Down voting an answer because you feel it isn't what you wanted to hear is extremely rude, unproductive and won't win you any points here. It will make it even less likely that others will want to help you in the future.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
So then...
Was this correct thinking?
I thought becase the Form was disposing all components including the hosted toolstrip (that I provided code for) that it was being disposed.
rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Sometimes compiler warnings can be very annoying.
Long ago, when I had to work with C++ and Visual Studio 6, there were those "performance warnings" of the compiler because of casting a BOOL into a bool (or vice versa) would slow down the application. That's when I learned to ignore the warnings.
Do not get discouraged by some of the replies you received to your post.
It is true that there were some posts by people who were simply too lazy to do some basic research in the web and expected other CodeProject members to be obliged to spoon-feed them the solution, and then the tone in the forums deteriorated. We should return to a more friendly behavior.
|
|
|
|
|
Thanks for the info Bernhard....
I work in a vacuum here….I don’t have to rely on this as an income I play with this stuff because it’s fun. But from time-to-time I need someone to bounce stuff off of because there is a sea of information out there but to be honest most of it is not very useful. There’s big difference between reading information and understanding it.
Thanks to all for your time and responses
rafome
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Hi Guys,
I want to know how to get the correct character from a unicode value which has a surrogate key. For example:
Here is my code that works with most characters:
public static char ConvertUnicodeToCharacter(string unicodeValue)
{
int unicode = int.Parse(unicodeValue.Substring(2), NumberStyles.HexNumber);
return (char)unicode;
}
This will take in something (like U+3400 for example) and spit out the character (in this case: 㐀).
When I try this one: U+2A601, I always get this: ꘁ, but it should be this: 𪘁.
Info on surrogate pairs:
"UTF-16 Encoding Form. The Unicode encoding form that assigns each Unicode scalar value in the ranges U+0000..U+D7FF and U+E000..U+FFFF to a single unsigned 16-bit code unit with the same numeric value as the Unicode scalar value, and that assigns each Unicode scalar value in the range U+10000..U+10FFFF to a surrogate pair" - http://www.unicode.org/glossary/
I just want to convert U+2A601 to 𪘁. Anyone know how?
Thanks
|
|
|
|
|
gordon_matt wrote: I just want to convert U+2A601 to 𪘁. Anyone know how?
This is 20-bits and therefore not a Unicode character; are you sure this value is correct?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
|
gordon_matt wrote: I'm not sure what you're on about with the 20-bits thing
Hex value 2A601 is five digits which is 20-bits, Unicode characters are only 16 bits. I'm not sure what translation table is being used in the link you posted, but I would suggest an email to the person who made the website as the best step forward.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Richard MacCutchan wrote: Hex value 2A601 is five digits which is 20-bits, Unicode characters are only 16 bits
In what context?
Unicode as a standard supports any number of character sets. Bits has nothing to do with that.
Each set is demarked by a minimum representational size called a code point which can be 8 bits, 16 bits, 32 bits and even 64 bits.
The full range of characters in each set (which is not necessarily all possible unicode characters) is represented by one or more code points.
The OP is asking about surrogate pairs in a 16 bit set. A suitable description of that is found here. One can find it at unicode.org as well but is requires digging.
http://en.wikipedia.org/wiki/UTF-16/UCS-2[^]
And C# certainly supports surrogate pairs. The following references the upper limit of 10FFFF which would be 21 bits. And 2A601 is certainly in that range.
http://msdn.microsoft.com/en-us/library/aa664669(v=vs.71).aspx[^]
Perhaps you are stating that 2A601 is not a valid character in the character set?
|
|
|
|
|
Very interesting, and I stand corrected. But what is the answer to the OP's question?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
gordon_matt wrote: I want to know how to get the correct character from a unicode value which has a surrogate key. For example:
The data type 'char' only has 16 bits.
For C# the full range of unicode characters extends to 10FFFF, which will not fit in a 'char'.
The char represents a code point not a character in the full range of unicode character set.
A surrogate pair is by definition two code points. So to represent it you must have two 'char' values.
Alternatives would be to use an 'int' or a String.
|
|
|
|
|
Thanks for the reply. I understand this well enough, but maybe everyone here is not quite understanding what I want...
Okay don't return a System.Char... give me a System.String...whatever....
I just want to do something like this:
public string GetUnicodeCharacter(string uniValue)
{
//uniValue = "U+2A601"
//Do some logic
return myUnicodeCharacter; //string that will display 𪘁
}
It seems nobody knows how to get this and it is driving me nuts. Yes I did email the author of that site (cojak.org), but no reply yet; maybe because of holidays, but I'll be lucky if he helps me anyway (not to mention his site is PHP, so might not be able to help with .NET).
Maybe there is a way to get the surrogate values from the "U+2A601" string? Then I could do something (ugly as it may be) like this:
public string myImaginaryMethod()
{
string original = "\u2A601";
string highSurrogate = GetHighSurrogate(original);
string lowSurrogate = GetLowSurrogate(original); returns "\uDE01";
return highSurrogate + lowSurrogate;
}
Surely someone must know how to get this value somehow...anyhow...I don't care how, so long as I can get 𪘁 from "U+2A601"; (or from "\u2A601" would be fine too)
|
|
|
|
|
gordon_matt wrote: It seems nobody knows how to get this and it is driving me nuts
Mentioning the surrogate pair probably confused the issue. It certainly did for me.
The following code should be what you want (with appropriate bit manipulation.) If not then could you provide the unicode.org page reference for 2A601 (I couldn't find it.)
// 2A601
byte[] array = new byte[4];
int i=0;
array[i++] = (byte)0x0001; // Little endian
array[i++] = (byte)0x00A6;
array[i++] = (byte)0x0002;
array[i++] = (byte)0x0000;
String r = System.Text.Encoding.UTF32.GetString(array);
|
|
|
|
|
Thanks jschell. What Richard mentioned about it being 20 bits got me thinking this must be a UTF-32 character and after a LOT of research, I finally got the answer I needed and the solution is actually quite simple once you know what to look for:
If you pass in "U+2A601" to this method of mine, you'll get the correct character returned. I think I may go ahead and post a tip/trick on this
Thanks to all for helping point me in the right direction.
public static string ConvertUnicodeToCharacter(string unicodeValue)
{
int unicode = int.Parse(unicodeValue.Substring(2), NumberStyles.HexNumber);
if (unicodeValue.Length == 7)
{
return char.ConvertFromUtf32(unicode);
}
return ((char)unicode).ToString();
}
Cheers
|
|
|
|
|
I just came across this article[^] which may also contain some useful information.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I suspect the following would also work.
int unicode = int.Parse(unicodeValue.Substring(2), NumberStyles.HexNumber);
return char.ConvertFromUtf32(unicode);
|
|
|
|
|
You can parse the "U+XXXXX" string into a integer of unicode, which in your case should be unicode=0x0002A601. Then you can ensurrogate to have two integers hi and lo.
int unicode, hi, lo;
unicode=0x0002A601;
hi = (unicode - 0x10000) / 0x400 + 0xD800;
lo = (unicode - 0x10000) % 0x400 + 0xDC00;
string s = new String(new char[] { Convert.ToChar(hi), Convert.ToChar(lo) });
The string s is 𪘁.
BTW, dealing with unicode, you may want to use System.Globalization.StringInfo.GetTextElementEnumerator to get a TextElement, check MSDN for more details.
|
|
|
|