[gtkada] problem with Locale_to_UTF8??

James E.Hopper hopperj at macconnect.com
Sat Oct 2 21:46:34 CEST 2004


at least on the mac gtkada it appears that the routine above will raise 
INTERFACES.C.STRINGS.DEREFERENCE_ERROR exception if the locale is not 
set correctly (ie not set).  the line

       S   : constant Interfaces.C.Strings.chars_ptr := Internal 
(OS_String, OS_String'Length);

returns a null pointer.  perhaps this should be trapped by the routine 
and a more meaningful exception raised in its place outside the 
routine?

best jim


    function Locale_To_UTF8 (OS_String : String) return String is
       function Internal
         (OS_String     : String;
          Len           : Gsize;
          Bytes_Read    : System.Address := System.Null_Address;
          Bytes_Written : System.Address := System.Null_Address;
          Error         : GError_Access := null) return 
Interfaces.C.Strings.chars_ptr;
       pragma Import (C, Internal, "g_locale_to_utf8");

       S   : constant Interfaces.C.Strings.chars_ptr := Internal 
(OS_String, OS_String'Length);
       Str : constant String := Value (S);

    begin
       g_free (S);
       return Str;
    end Locale_To_UTF8;




More information about the gtkada mailing list