Retrieve values from the request

Hello guys, I am trying to get a field that contain special characteres like tildes, ñ and only I can get the part before the the first special characteres
How I can retrieve all string

I am using gin gonic framework and this statement “c.PostForm(“content”)”

Can you post some short code sample here (ideally one that is ready to run) that replicates the issue?

I am asking because Go’s string data type is Unicode-aware and therefore there should be no reason for stopping at non-ASCII characters.

If the input isn’t utf8 non ASCII can confuse the decoder.

Here is my code to save the post

func Create(c *gin.Context) {
cats := c.PostForm("cats")
	catsArray := strings.Split(cats, ",")

	tags := c.PostForm("tags")
	tagsArray := strings.Split(tags, ",")

	title := c.PostForm("title")
	content := c.PostForm("content")

	
	summary := c.PostForm("summary")
	fileLgId := c.DefaultPostForm("file_lg_id", "0")
	fileSgId := c.DefaultPostForm("file_sg_id", "0")
	visibility := c.PostForm("visibility")
	states := c.DefaultPostForm("status", "active" )
	sticky, err := strconv.ParseBool(c.PostForm("sticky"))


	if err != nil {
		log.Fatal(err)
	}
	fileLg, err := strconv.ParseInt(fileLgId, 10, 0)
	if err != nil {
		ErrorResponse(c, errors.New("Not valid file Id"))
	}

	fileSg, err := strconv.ParseInt(fileSgId, 10, 0)
	if err != nil {
		ErrorResponse(c, errors.New("Not valid file Id"))
	}

	post := pfdatabase.Post{
		Title:       title,
		Content:     content,
		Summary:     summary,
		FileLgId:    fileLg,
		FileSgId:    fileSg,
		Visibility:  visibility,
		Sticky:      sticky,
		Status:      states,
		AuthorId:    0,
		PublishedAt: "",
	}

	postId := pfdatabase.InsertPost(post)

	if postId > 0 {

		if len(catsArray) > 0 {
			//remove all cats
			pfdatabase.SetCategoryToPost(postId, catsArray)
		}

		if len(tagsArray) > 0 {
			//remove all post
			pfdatabase.SetTagToPost(postId, tagsArray)
		}
		c.JSON(http.StatusCreated, gin.H{
			"message":  postId,
		})
	} else {
		ErrorResponse(c, errors.New("Could not create the post. Internal server error"))
	}

}

and this the content that i sending

" Lorem Ipsum es simplemente el texto de relleno de las imprentas y archivos de texto. Lorem Ipsum ha sido el texto de relleno estándar de las industrias desde el año 1500, cuando un impresor (N. del T. persona que se dedica a la imprenta) desconocido usó una galería de textos y los mezcló de tal manera que logró hacer un libro de textos especimen. No sólo sobrevivió 500 años, sino que tambien ingresó como texto de relleno en documentos electrónicos, quedando esencialmente igual al original. Fue popularizado en los 60s con la creación de las hojas “Letraset”, las cuales contenian pasajes de Lorem Ipsum, y más recientemente con software de autoedición, como por ejemplo Aldus PageMaker, el cual incluye versiones de Lorem Ipsum."

And this is what I get after make “content := c.PostForm(“content”)” and print out using fmt.Println(content)

Lorem Ipsum es simplemente el texto de relleno de las imprentas y archivos de texto. Lorem Ipsum ha sido el texto de relleno est&aacute”

The word estándar in the text contain tildes.

Sorry about big text

And which encoding do you use?

Are you able to post the full request you actually send?

Ps: I’d prefer of course a massively shortened input that reproduces the problem and a hex dump of the request as it gone over the wire.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.