Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6368785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:43:11+00:00 2026-05-25T00:43:11+00:00

I am working on improving a stream reader class that uses a BinaryReader .

  • 0

I am working on improving a stream reader class that uses a BinaryReader. It consists of a while loop that uses .PeekChar() to check if more data exists to continue processing.

The very first operation is a .ReadInt32() which reads 4 bytes. What if PeekChar only “saw” one byte (or one bit)? This doesn’t seem like a reliable way of checking for EOF.

The BinaryReader is constructed using its default parameters, which as I understand it, uses UTF8 as the default encoding. I assume that .PeekChar() checks for 8 bits but I really am not sure.

How many bits does .PeekChar() look for? (and what are some alternate methods to checking for EOF?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:43:12+00:00Added an answer on May 25, 2026 at 12:43 am

    Here BinaryReader.PeekChar

    I read:

    ArgumentException: The current character cannot be decoded into the
    internal character buffer by using the Encoding selected for the
    stream.

    This makes clear that amount of memory read depends on Encoding applied to that stream.

    EDIT

    Actually definition according to MSDN is:

    Returns the next available character and does not advance the
    byte or character position.*

    Infact, it depends on encoding if this is a byte or more…

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are working on improving our DAL which is written in LINQ that talks
I'm currently working on some R&D for improving the process and practice that we
I am working on improving our glossary functionality in a custom CMS that is
Context I am working on improving my JavaScript skills and I'm learning more about
I'm working on improving our group's development process, and I'm considering how best to
I am currently working on automating/improving the release process for packaging my shop's entire
I've recently been working through a large codebase, refactoring and generally improving design to
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a project that parses a log of events, and then updates a
I'm working on a Grails web app that would be similar in access patterns

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.