Click here to Skip to main content
15,887,344 members
Home / Discussions / C#
   

C#

 
QuestionError: Operator '>' cannot be applied to operands of type 'double' and 'System.Random' Pin
Member 117477347-Jun-15 2:37
Member 117477347-Jun-15 2:37 
AnswerRe: Error: Operator '>' cannot be applied to operands of type 'double' and 'System.Random' Pin
Sascha Lefèvre7-Jun-15 2:59
professionalSascha Lefèvre7-Jun-15 2:59 
GeneralRe: Error: Operator '>' cannot be applied to operands of type 'double' and 'System.Random' Pin
Member 117477347-Jun-15 3:00
Member 117477347-Jun-15 3:00 
AnswerRe: Error: Operator '>' cannot be applied to operands of type 'double' and 'System.Random' Pin
Dave Kreskowiak7-Jun-15 3:15
mveDave Kreskowiak7-Jun-15 3:15 
AnswerRe: Error: Operator '>' cannot be applied to operands of type 'double' and 'System.Random' Pin
Afzaal Ahmad Zeeshan7-Jun-15 4:24
professionalAfzaal Ahmad Zeeshan7-Jun-15 4:24 
QuestionHow public static declaration for Statusbar Control ? Pin
Member 24584676-Jun-15 23:41
Member 24584676-Jun-15 23:41 
AnswerRe: How public static declaration for Statusbar Control ? Pin
OriginalGriff6-Jun-15 23:57
mveOriginalGriff6-Jun-15 23:57 
QuestionHow to split UTF16 stream Pin
Super Lloyd5-Jun-15 2:22
Super Lloyd5-Jun-15 2:22 
I am trying to create some CircularStream and / or CircularTextWriter.
When It reach its limit it should continue writing from the start again.

I got 2 problems:
- if I use UTF16 encoding I am not sure whether a given byte is in the middle of a character or not
- even if I use UTF32 I can't cut the stream every 4 bytes as damn unicode characters might need to come in pair sometimes.

basically.. how I like to know... where to split a char[] at a legal place...

[EDIT] kind of fixed...
I create a Stream (view) of the beginning of my CircularStream and read it with Stream Writer and do some educated guess with the StringInfo class

[EDIT2]
Because splitting on char is too hard (2 char might work together depending on the whole line) I decided to split only at line returns!
For the record here is how I read char from the stream:
C#
const int bit00 = 0x00; // 00000000
const int bit10 = 0x80; // 10000000
const int bit20 = 0xC0; // 11000000
const int bit30 = 0xE0; // 11100000
const int bit40 = 0xF0; // 11110000
const int bit50 = 0xF8; // 11111000
const int bit07 = 0x7F; // 01111111
const int bit06 = 0x3F; // 00111111
const int bit05 = 0x1F; // 00011111
const int bit04 = 0x0F; // 00001111
const int bit03 = 0x07; // 00000111

public static int ReadUTF8Char(Stream s)
{
    int c = s.ReadByte();
    if (c == -1)
    {
        return -1;
    }
    else if ((c & bit10) == bit00)
    {
        return c;
    }
    else if ((c & bit30) == bit20)
    {
        var c2 = s.ReadByte();
        return c & bit05 << 6 | c2 & bit06;
    }
    else if ((c & bit40) == bit30)
    {
        var c2 = s.ReadByte();
        var c3 = s.ReadByte();
        return c & bit04 << 12 | c2 & bit06 << 6 | c3 & bit06;
    }
    else if ((c & bit50) == bit40)
    {
        var c2 = s.ReadByte();
        var c3 = s.ReadByte();
        var c4 = s.ReadByte();
        return c & bit03 << 18 | c2 & bit06 << 12 | c3 & bit06 << 6 | c2 & bit06;
    }
    else
    {
        // what is that?
        return c;
    }
}
All in one Menu-Ribbon Bar
DirectX for WinRT/C# since 2013!
Taking over the world since 1371!


modified 5-Jun-15 22:22pm.

SuggestionRe: How to split UTF16 stream Pin
Richard MacCutchan5-Jun-15 2:29
mveRichard MacCutchan5-Jun-15 2:29 
GeneralRe: How to split UTF16 stream Pin
Super Lloyd5-Jun-15 2:37
Super Lloyd5-Jun-15 2:37 
SuggestionRe: How to split UTF16 stream Pin
Sascha Lefèvre5-Jun-15 2:57
professionalSascha Lefèvre5-Jun-15 2:57 
GeneralRe: How to split UTF16 stream Pin
Super Lloyd5-Jun-15 5:06
Super Lloyd5-Jun-15 5:06 
QuestionTCP Server Multiple Clients (Server Initiation Connection) Pin
MooKowMyke4-Jun-15 12:48
MooKowMyke4-Jun-15 12:48 
AnswerRe: TCP Server Multiple Clients (Server Initiation Connection) Pin
Richard Andrew x644-Jun-15 13:55
professionalRichard Andrew x644-Jun-15 13:55 
GeneralRe: TCP Server Multiple Clients (Server Initiation Connection) Pin
MooKowMyke9-Jun-15 9:04
MooKowMyke9-Jun-15 9:04 
QuestionHelp using EF with DB2 Pin
USAFHokie804-Jun-15 2:56
USAFHokie804-Jun-15 2:56 
AnswerRe: Help using EF with DB2 Pin
Richard MacCutchan4-Jun-15 4:29
mveRichard MacCutchan4-Jun-15 4:29 
QuestionC# Newbie. Need help on coding a errorcheck Pin
Setasigge4-Jun-15 2:24
Setasigge4-Jun-15 2:24 
AnswerRe: C# Newbie. Need help on coding a errorcheck Pin
Eddy Vluggen4-Jun-15 2:59
professionalEddy Vluggen4-Jun-15 2:59 
AnswerRe: C# Newbie. Need help on coding a errorcheck Pin
Richard MacCutchan4-Jun-15 4:27
mveRichard MacCutchan4-Jun-15 4:27 
GeneralRe: C# Newbie. Need help on coding a errorcheck Pin
Setasigge4-Jun-15 21:04
Setasigge4-Jun-15 21:04 
GeneralRe: C# Newbie. Need help on coding a errorcheck Pin
Richard MacCutchan4-Jun-15 21:37
mveRichard MacCutchan4-Jun-15 21:37 
GeneralRe: C# Newbie. Need help on coding a errorcheck Pin
Setasigge4-Jun-15 22:01
Setasigge4-Jun-15 22:01 
GeneralRe: C# Newbie. Need help on coding a errorcheck Pin
Richard MacCutchan5-Jun-15 0:27
mveRichard MacCutchan5-Jun-15 0:27 
QuestionImplementing PocketSphinx in C# Pin
Member 105130663-Jun-15 21:14
Member 105130663-Jun-15 21:14 

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.