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á”
The word estándar in the text contain tildes.
Sorry about big text