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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:48:08+00:00 2026-06-03T10:48:08+00:00

Here is my little code: var http = require(‘http’); var port = 9002; var

  • 0

Here is my little code:

var http = require('http');
var port = 9002;
var host_ip = '<my_ip>';
http.createServer(function (req, res) {
    var content = new Buffer("Hello 世界", "utf-8")
    console.log('request arrived');
    res.writeHead(200, {
        'Content-Encoding':'utf-8',
        'charset' : 'utf-8',
        'Content-Length': content.length,
        'Content-Type': 'text/plain'});
    res.end(content.toString('utf-8'),'utf-8');
}).listen(port, host_ip);
console.log('server running at http://' + host_ip + ':' + port);

Previously I just let res.end to send “hello world” and it worked well. Then I wanted to adjust a little bit and changed the ‘world’ into the Chinese equivalent ‘世界’, and so changed the ‘charset’ ‘content-type’ in the header to ‘utf-8’. But in Chrome and Firefox I see this:

hello 涓栫晫

However, amazingly opera(11.61) does show the correct result hello 世界. I want to know whether I have missed something in the code, and why this is happening. Thank you guys.

I think this post is similiar with my situation but not exactly.

  • 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-06-03T10:48:17+00:00Added an answer on June 3, 2026 at 10:48 am

    Problem is with the character set specification. For me it works with this change:

    'Content-Type': 'text/plain;charset=utf-8'
    

    Tested with Chrome, Firefox and Safari.

    You could also look into the node.js package “express” which allows rewriting your code like this:

    var express=require('express');
    
    var app=express.createServer();
    
    app.get('/',function(req, res) {
        var content = "Hello 世界";
    
        res.charset = 'utf-8';
        res.contentType('text');
        res.send(content);
    });
    
    app.listen(9002);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code here is X++. I know very little about it, though I am
i've a jquery (UI) App here where the whole JQuery Code gets a little
I have a little bit of Javascript that almost works correctly. Here's the code:
Just a little confused here... I have a function in postgres, and when I'm
Going a little insane here. Here is the jsfiddle: http://jsfiddle.net/mersenneprimes/CvGKK/ Note business is in
I made a neat little photo gallery here at - http://schnell.dreamhosters.com/wallpapers.php Feel free to
Download the source code with compiled executable here (Size: 161 KB (165,230 bytes)): http://www.eyeClaxton.com/download/delphi/ColorSwap.zip
There’s a really cool diff class hosted by Google here: http://code.google.com/p/google-diff-match-patch/ I’ve used it
here's my javascript phonegap code, and, when i try tu upload a little file
A little stuck here. I have a simple question I guess. Given the following

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.