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 5942915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:19:14+00:00 2026-05-22T16:19:14+00:00

If I input a UTF-8 encoded file like, example.html <html> <head> <meta http-equiv=Content-Type content=text/html;charset=utf-8>

  • 0

If I input a UTF-8 encoded file like,

example.html

<html>
<head>
<meta http-equiv=Content-Type content="text/html;charset=utf-8">
<title>Текст на русском</title>

Where “Текст на русском” – Is text in russian

#include <string>
#include <ios>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#include <stdio.h>

using namespace std;
int main () 
{
int fl; unsigned int nbytes = 60000,bspr; char buf [60000];
errno_t err = _wsopen_s(&fl,L"c:\\example.html", _O_U8TEXT,_SH_DENYNO,_S_IREAD | _S_IWRITE ); // &fh,"c:\\example.html",_O_RDONLY, 
if ( err!=0 ) exit (1);
if ((bspr = _read(fl,buf,nbytes))<=0 )
{
    perror (" Error opening file ");
    exit (1);
}

}

I get buf[0]=60 ‘<‘, buf[1]=0, buf[2]=104 ‘h’,buf[3]=0, and so on

until i reach russian letters, then i get totally improper symbols like 20 ” each followed by 4 ”,

‘char’ – is the vstudio output of this character .. strangely same for 20 and 4.

So the question is – Is there any way I can get output buffer to a string till EOF, formatted properly , even if not using this operator ?

  • 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-22T16:19:15+00:00Added an answer on May 22, 2026 at 4:19 pm

    It looks like _O_U8TEXT causes _read to convert from UTF-8 to UTF-16. You should probably be reading using high-level Unicode functions like getwc when opening a stream in a unicode mode. You could use _wfopen_s with L"rt, ccs=UTF-8", or if you need the sharing support you could use your existing _wsopen_s call followed by _wfdopen.

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

Sidebar

Related Questions

I am playing with the Unix hexdump utility. My input file is UTF-8 encoded,
I have an HTML file (encoded in utf-8). I open it with codecs.open() .
Input: I have a LaTeX file, with plain text & math formulas. Desired output:
Is it possible to use ReadList to read UTF-8 (or any other) encoded text
My Perl program takes some text from a disk file as input, wraps it
I have a file encoded in UTF-8 which I want to read in java,
I want to read UTF-8 input in Perl, no matter if it comes from
It seems that flex doesn't support UTF-8 input. Whenever the scanner encounter a non-ASCII
I'm getting the error: parser error : Input is not proper UTF-8, indicate encoding
we are accepting all sorts of national characters in UTF-8 string on the input,

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.