C#で文字コードを判別する方法

| コメント(17) | トラックバック(0)
なんちゃってVS使いになって2週間、すっかり自分のものにしてせこせこ書いてます(笑)
ただ一点かなりはまったのが文字コードの判別。

PHPとかPerlとか文字コードを自動判別するメソッドが標準や準標準でついているのに
.netframeworkにはついてないしw
Windowsアプリではそんなに文字コード判別することってないのかなぁ?
とも一瞬思いかけたけど ファイルの読み込みとか普通にするはずだし どうにかならないものか?

と思ったらやっぱりありました。

PerlのJCode.pmの文字コード判別メソッドから移植してメソッドとして公開している方がいました。

いやー 感謝、感謝!

http://dobon.net/vb/dotnet/string/detectcode.html


ちなみにbyte[]を文字コード判別するけど stringの文字コード判別はこのメソッドだとできないんですね。。。
んで stringからbyte[]に変換することはできるけど Encodingクラス使って変換するには
stringの文字コードがわからないとできなくて・・・
文字コード判別するためにbyte[]に変換したいのに文字コードがわからないから変換できない、というデッドロック状態(笑)

とりあえず自分に必要な仕様としては問題ないからスルーしてるけど string型を引数にして文字コード判別するプログラム作ってる人いないのかなぁ?


まぁなんにせよC#ってJavaっぽい感じなので なんちゃってC#使いだけどすっかりC#マスター気分です(笑)

トラックバック(0)

トラックバックURL: http://blog.romaji.net/mt4/mt_cgi/mt-tb.cgi/79

コメント(17)

こちらも変な勘違いをされていますね。

>stringの文字コードがわからないとできなくて・・・

stringに文字コードの概念は必要ありません。
内部保持しているバイトコードは常にUnicodeとして扱われます。
http://msdn.microsoft.com/ja-jp/library/362314fe(VS.80).aspx
http://dobon.net/vb/dotnet/string/getencoding.html
http://msdn.microsoft.com/ja-jp/library/system.text.encoding.convert(VS.71).aspx
http://msdn.microsoft.com/ja-jp/library/system.text.encoding.getbytes(VS.71).aspx

このあたりを、じっくりしっかり読んでみることをお勧めします。理解出来れば何のことはない話ですが。

Mornin ! I had put together subscribed your internet site for interesting content, I will be also about to commence a blog on health product vigrx plus , it's also possible to find some original unique content for me personally on cheap vigrx plus. Ciao!

Youre so cool! I dont suppose Ive learn like this before. So nice to discover any person with authentic tips on this subject. realy we appreciate you beginning this up. this site is a thing thats needed over the internet, someone with a dose of originality. useful task for bringing new stuff towards web!

If you're searching for SEO services, come check out our website.

Now im so fond of this url , it aids me much with foregathering excellent information on tips on how to handle myself.

The contextual educating style featured within the Jamorama won't create training by yourself is likely to room for too long periods at a time looking forward to a small improvement. The easiest way to gain knowledge music would be to use other, better, musicians. Jamorama provides you with that has a way to learn from all very reputable qualified person guitarists, which feature jam monitor recordings that let you play plus the pros. This extensive multimedia package deal carries a guitar-playing tuition book, ear schooling game, music browsing game, tuning software, a metronome, and video lessons.

I will be impressed, I have to say. Really rarely should i discovered your blog that may be both educative and entertaining, and without a doubt, youve hit the nail within the head. Your article is outstanding; the issue is an issue that not many everyone is speaking intelligently about. Im very happy that we found this around my seek out something concerning this.

Wow, I became lucky to seek out this website after i was ready for some good information on Bing! Maintain the nice work!

Hi, I stumbled upon your posts by accident after i was searching bing for this issue, Need to say your page is absolutely helpful Furthermore love the theme, its amazing!. I don't possess that much time and energy to look into all your post right now but I have saved it and in addition add your Bottles. We're way back in in one day. appreciate your a great website.

Just carry on doing good content.

What a lovely day for a 2424240! SCK was here

I together with my guys have been going through the great key points located on your web blog then then developed an awful feeling I never expressed respect to the website owner for those strategies. All the young boys were so glad to learn them and already have surely been taking pleasure in these things. Appreciate your being considerably considerate as well as for considering this form of superior subject areas millions of individuals are really eager to be informed on. Our honest apologies for not expressing appreciation to you earlier.

Zune and iPod: Most people compare the Zune to the Touch, but after seeing how slim and surprisingly small and light it is, I consider it to be a rather unique hybrid that combines qualities of both the Touch and the Nano. It's very colorful and lovely OLED screen is slightly smaller than the touch screen, but the player itself feels quite a bit smaller and lighter. It weighs about 2/3 as much, and is noticeably smaller in width and height, while being just a hair thicker.

Today, while I was at work, my cousin stole my iphone and tested to see if it can survive a twenty five foot drop, just so she can be a youtube sensation. My iPad is now destroyed and she has 83 views. I know this is entirely off topic but I had to share it with someone!

Those are yours alright! . We at least need to get these people stealing images to start blogging! They probably just did a image search and grabbed them. They look good though!

Having such an abundance of content do you ever run across any kind of challenges associated with plagiorism or copyright infringement? My web page has many completely unique content I’ve either authored myself or outsourced even so it looks a lot of it is actually popping it up all over the web without my approval. Have you any idea any ways of protect against information from getting stolen? I’d absolutely appreciate it.

After examine a couple of of the blog posts on your web site now, and I actually like your approach of blogging. I bookmarked it to my bookmark web site checklist and might be checking again soon. Pls try my web site as nicely and let me know what you think.

コメントする

2011年9月

        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30