Click here to Skip to main content
15,867,307 members
Home / Discussions / C#
   

C#

 
GeneralRe: how draw border on round image png? Pin
Le@rner15-Aug-22 21:38
Le@rner15-Aug-22 21:38 
GeneralRe: how draw border on round image png? Pin
Richard MacCutchan15-Aug-22 22:13
mveRichard MacCutchan15-Aug-22 22:13 
AnswerRe: how draw border on round image png? Pin
Gerry Schmitz16-Aug-22 9:57
mveGerry Schmitz16-Aug-22 9:57 
Question.NET and c# windows form app Pin
Баярдаваа Ихтамир8-Aug-22 22:01
Баярдаваа Ихтамир8-Aug-22 22:01 
AnswerRe: .NET and c# windows form app Pin
Richard Deeming8-Aug-22 22:42
mveRichard Deeming8-Aug-22 22:42 
AnswerRe: .NET and c# windows form app Pin
OriginalGriff9-Aug-22 0:36
mveOriginalGriff9-Aug-22 0:36 
AnswerRe: .NET and c# windows form app Pin
Gerry Schmitz9-Aug-22 9:19
mveGerry Schmitz9-Aug-22 9:19 
QuestionDecoding GBK, .NET 6 edition Pin
harold aptroot8-Aug-22 12:07
harold aptroot8-Aug-22 12:07 
I have some CSV files encoded in GBK, aka codepage 936, and need to load them as strings (or something sufficiently string-like, whatever) for further processing. In the old days, I could call some function such as File.ReadAllText (or read the file line by line etc) and specify CP936 as the encoding. But in .NET 6, I can't. The only valid options are ASCII, Latin 1, and a couple of flavours of UTF.

That sounds unlikely, right? But here is the documentation for the Encoding class, and in the big table halfway down the page, you can see that almost everything is gone. Almost as if the thinking is now "people should just use UTF-8 or UTF-16 nowadays". If it were up to me, those file would be encoded in UTF-8, but they're just not.

So, right now what I do is this, assuming that I've read the file into an array byte[] raw and int size bytes were successfully read into it:
C#
char[] buffer = new char[size];
int numberOfChars;
fixed (char* bufferptr = buffer)
fixed (byte* rawptr = raw)
    numberOfChars = MultiByteToWideChar(936, 0, rawptr, readSize, bufferptr, buffer.Length);
Calling MultiByteToWideChar via a dllimport. Then afterwards I can use numberOfChars to create a Span<char> of the appropriate length.

That works, but it seems like a serious step backwards compared to .NET 4. Also there seems to be no way (no reasonable way anyway) to read/convert chunks of the file this way, as MultiByteToWideChar does not report the leftover bytes at the end of the chunk.

Are there any better options?
AnswerRe: Decoding GBK, .NET 6 edition Pin
lmoelleb8-Aug-22 22:02
lmoelleb8-Aug-22 22:02 
GeneralRe: Decoding GBK, .NET 6 edition Pin
lmoelleb8-Aug-22 23:22
lmoelleb8-Aug-22 23:22 
AnswerRe: Decoding GBK, .NET 6 edition Pin
Richard Deeming8-Aug-22 22:34
mveRichard Deeming8-Aug-22 22:34 
GeneralRe: Decoding GBK, .NET 6 edition Pin
harold aptroot9-Aug-22 4:44
harold aptroot9-Aug-22 4:44 
QuestionHow to close FileStream without causing an error in PdfViewer Pin
Code4Ever7-Aug-22 20:02
Code4Ever7-Aug-22 20:02 
AnswerRe: How to close FileStream without causing an error in PdfViewer Pin
OriginalGriff7-Aug-22 20:25
mveOriginalGriff7-Aug-22 20:25 
GeneralRe: How to close FileStream without causing an error in PdfViewer Pin
Code4Ever7-Aug-22 20:38
Code4Ever7-Aug-22 20:38 
GeneralRe: How to close FileStream without causing an error in PdfViewer Pin
OriginalGriff7-Aug-22 21:16
mveOriginalGriff7-Aug-22 21:16 
GeneralRe: How to close FileStream without causing an error in PdfViewer Pin
OriginalGriff7-Aug-22 21:59
mveOriginalGriff7-Aug-22 21:59 
AnswerRe: How to close FileStream without causing an error in PdfViewer Pin
Richard Deeming8-Aug-22 0:08
mveRichard Deeming8-Aug-22 0:08 
QuestionFacing problem when calling store procedure from c# code Pin
Mou_kol2-Aug-22 7:52
Mou_kol2-Aug-22 7:52 
AnswerRe: Facing problem when calling store procedure from c# code Pin
Richard Deeming2-Aug-22 21:21
mveRichard Deeming2-Aug-22 21:21 
GeneralRe: Facing problem when calling store procedure from c# code Pin
Mou_kol3-Aug-22 3:27
Mou_kol3-Aug-22 3:27 
GeneralRe: Facing problem when calling store procedure from c# code Pin
Victor Nijegorodov3-Aug-22 5:33
Victor Nijegorodov3-Aug-22 5:33 
QuestionRe: Facing problem when calling store procedure from c# code Pin
thatraja2-Aug-22 21:36
professionalthatraja2-Aug-22 21:36 
AnswerRe: Facing problem when calling store procedure from c# code Pin
Gerry Schmitz3-Aug-22 5:58
mveGerry Schmitz3-Aug-22 5:58 
QuestionHow to dispose Interaction.Behaviors in WPF Pin
Code4Ever2-Aug-22 5:45
Code4Ever2-Aug-22 5:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.