httpx icon indicating copy to clipboard operation
httpx copied to clipboard

Get Chinese garbled title

Open b1win0y opened this issue 2 years ago • 1 comments

I use the httpx program under the terminal to get the title as normal Chinese, but when I get the title through code, it is garbled. my httpx version is 1.3.7 and I use the following code to get the title and get garbled characters

package main

import (
	"fmt"
	"log"
	"github.com/projectdiscovery/goflags"
	"github.com/projectdiscovery/gologger"
	"github.com/projectdiscovery/gologger/levels"
	"github.com/projectdiscovery/httpx/runner"
)

func main() {
	gologger.DefaultLogger.SetMaxLevel(levels.LevelVerbose)
	options := runner.Options{
		Methods:         "GET",
		InputTargetHost: goflags.StringSlice{"http://103.45.249.230:7878/"},
		//InputFile: "./targetDomains.txt", // path to file containing the target domains list
		OnResult: func(r runner.Result) {
			fmt.Println("Title:", r.Title)
			fmt.Println("Raw:", r.Raw)
			// handle error
			if r.Err != nil {
				fmt.Printf("[Err] %s: %s\n", r.Input, r.Err)
				return
			}
			fmt.Printf("%s %s %d\n", r.Input, r.Host, r.StatusCode)
		},
	}
	if err := options.ValidateOptions(); err != nil {
		log.Fatal(err)
	}
	httpxRunner, err := runner.New(&options)
	if err != nil {
		log.Fatal(err)
	}
	defer httpxRunner.Close()
	httpxRunner.RunEnumeration()
}
image and the Chinese content of the body is also garbled,Please tell me how to solve this problem?

I think it may be related to the gb2312 encoding

b1win0y avatar Dec 20 '23 10:12 b1win0y

This is simple a lack of fonts on your system. If you want to actually see the unicode, ensure you have fonts that support high level unicode. Some of the fonts i installed are: font-unifont-bdf freefont-ttf noto-fonts-ttf noto-fonts-ttf-extra noto-fonts-cjk noto-fonts-emoji

Also, MOST terminals are using utf8 by default, but make sure your locales are setup to us en_US UTF-8 or w.e in /etc/locale or whereever its managed on your system.

edit: this can be closed now btw

acidvegas avatar Dec 22 '23 03:12 acidvegas

Closing as the issue seems unrelated to the tool

Mzack9999 avatar May 07 '24 13:05 Mzack9999