Index: gimp/plug-ins/common/psd-save.c
===================================================================
--- gimp/plug-ins/common/psd-save.c	(revision 22767)
+++ gimp/plug-ins/common/psd-save.c	(working copy)
@@ -153,6 +153,7 @@
 static void   xfwrite              (FILE *fd, void *buf, long len, gchar *why);
 static void   write_pascalstring   (FILE *fd, char *val, gint padding,
                                     gchar *why);
+static void   write_unicodepascalstring   (FILE *fd, char *val, gchar *why);
 static void   write_string         (FILE *fd, char *val, gchar *why);
 static void   write_gchar          (FILE *fd, guchar val, gchar *why);
 static void   write_gint16         (FILE *fd, gint16 val, gchar *why);
@@ -381,6 +382,37 @@
 
 
 static void
+write_unicodepascalstring (FILE *fd, char *val, gchar *why)
+{
+  unsigned char len;
+  guint32 count;
+
+  gchar *luniName = g_convert (val, -1, "UCS-2", "UTF-8", NULL, NULL, NULL);
+
+  /* PS still limits string length to 255 chars */
+
+  len = (strlen (val) > 255) ? 255 : (unsigned char) strlen (val);
+
+  /* Perform actual writing */
+
+  if (len !=  0)
+    {
+      write_gint32 (fd, len, why);
+      for (count=0; count < len*2; count+=2)
+        write_gint16 (fd, luniName[count], why);
+
+      /* Pad to an even number of chars */
+      if (len % 2)
+        write_gint16 (fd, 0x0000, why);
+    }
+  else
+    write_gint32 (fd, 0, why);
+
+  fflush( fd );
+}
+
+
+static void
 xfwrite (FILE *fd, void *buf, long len, gchar *why)
 {
   if (fwrite (buf, len, 1, fd) == 0)
@@ -920,6 +952,7 @@
   gint     nChannelsLayer;              /* Number of channels of a layer */
   gint32   ChanSize;                    /* Data length for a channel */
   gchar   *layerName;                   /* Layer name */
+  gint32   xdBlockSize;                 /* Data length for an extra data block */
   gint     mask;                        /* Layer mask */
 
   glong    eof_pos;                     /* Position: End of file */
@@ -1072,6 +1105,20 @@
       write_pascalstring (fd, layerName, 4, "layer name");
       IFDBG printf ("\t\tLayer name: %s\n", layerName);
 
+      // Write 'luni' Block
+      xdBlockSize = strlen (layerName);
+
+      /* Only pads to even num of chars */
+      if (xdBlockSize % 2)
+        xdBlockSize++;
+
+      /* 2 bytes / char + 4 bytes for pascal num chars */
+      xdBlockSize = (xdBlockSize * 2) + 4;
+
+      xfwrite (fd, "8BIMluni", 8, "luni xdb signature");
+      write_gint32 (fd, xdBlockSize, "luni xdb size");
+      write_unicodepascalstring (fd, layerName, "luni xdb layer name");
+
       /* Write real length for: Extra data */
 
       eof_pos = ftell (fd);
