nominal fix for sending UTF-8 text to Mackie surface
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 15 Dec 2014 19:44:05 +0000 (14:44 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 15 Dec 2014 19:44:05 +0000 (14:44 -0500)
libs/surfaces/mackie/strip.cc

index 2b9167e3862d8cde6153756c349c225f1253e509..cfb4592f80c8fbe5ec3665824ed47eeca46e304b 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <sys/time.h>
 
+#include <glib.h>
+
 #include "midi++/port.h"
 
 #include "pbd/compose.h"
@@ -351,7 +353,7 @@ Strip::notify_property_changed (const PropertyChange& what_changed)
                } else {
                        line1 = PBD::short_version (fullname, 6);
                }
-
+               
                _surface->write (display (0, line1));
        }
 }
@@ -755,10 +757,16 @@ Strip::display (uint32_t line_number, const std::string& line)
        // offset (0 to 0x37 first line, 0x38 to 0x6f for second line)
        retval << (_index * 7 + (line_number * 0x38));
        
-       // ascii data to display
-       retval << line;
+       // ascii data to display. @param line is UTF-8
+       string ascii = g_str_to_ascii (line.c_str(), 0);
+       string::size_type len = ascii.length();
+       if (len > 6) {
+               ascii = ascii.substr (0, 6);
+               len = 6;
+       }
+       retval << ascii;
        // pad with " " out to 6 chars
-       for (int i = line.length(); i < 6; ++i) {
+       for (int i = len; i < 6; ++i) {
                retval << ' ';
        }