Golang - 从字符串中删除所有Unicode换行符

时间:2016-07-11 11:20:46

标签: go unicode utf-8

如何从GoLang中的UTF-8字符串中删除所有Unicode换行符?我找到了this answer for PHP

1 个答案:

答案 0 :(得分:4)

您可以使用strings.Map

           String jpg1 = FrameImageFilePath;
            String jpg2 = InnerImageFilePath;
            String jpg3 = OutputFilePath;

            Image img1 = Image.FromFile(jpg1);
            Image img2 = Image.FromFile(jpg2);

            int width = img1.Width;
            int height = img1.Height;

            Bitmap img3 = new Bitmap(img1.Width, img1.Height);
            Bitmap img2Resized = new Bitmap(img2, width, height);
            Graphics g = Graphics.FromImage(img3);

            g.Clear(Color.Black);
            g.DrawImage(img2Resized, new Point(0, 0));
            g.DrawImage(img1, new Point(0, 0));

            g.Dispose();
            img1.Dispose();
            img2.Dispose();

            img3.Save(jpg3, System.Drawing.Imaging.ImageFormat.Jpeg);
            img3.Dispose();

playground