glib

printing utf8 in glib

纵然是瞬间 提交于 2019-12-06 00:33:17
问题 Why utf8 symbols cannot be printed via glib functions? Source code: #include "glib.h" #include <stdio.h> int main() { g_print("марко\n"); fprintf(stdout, "марко\n"); } Build it like this: gcc main.c -o main $(pkg-config glib-2.0 --cflags --libs) You could see that glib can't print utf8 and fprintf can: [marko@marko-work utf8test]$ ./main ????? марко 回答1: fprint functions assume that every string you print with them is correctly encoded to match the current encoding of your terminal. g_print()

Vala vapi files documentation

99封情书 提交于 2019-12-05 15:17:29
问题 I'd like to hack on an existing GLib based C project using Vala. Basically what I'm doing is, at the beginning of my build process, using valac to generate .c and .h files from my .vala files and then just compiling the generated files the way I would any .c or .h file. This is probably not the best way, but seems to be working alright for the most part. My problem is that I'm having a hard time accessing my existing C code from my Vala code. Is there an easy way to do this? I've tried

glib network connection example

倖福魔咒の 提交于 2019-12-05 14:56:14
Can you advice some network connection example made with glib/gio libraries. There is quite a good reference manual , but no full example even for basic things. It will be used for simple sending and receiving files as a part of program. Yasushi Shoji How about like this? There is similar question at Fetch a file from web: in GTK using C #include <gio/gio.h> int main() { const gchar *uri = "https://stackoverflow.com/questions/5758770/"; GFile *in; GFile *out; GError *error = NULL; gboolean ret; g_type_init(); in = g_file_new_for_uri(uri); out = g_file_new_for_path("/tmp/a"); ret = g_file_copy

Within Python, what is exactly a sequence of strings? (or else Glib bug?)

假如想象 提交于 2019-12-05 12:00:18
I know the question may looks stupid, but I am really not able to figure it out. I naively though a sequence of strings is a list of strings. However, this fails: (pid, stdin, stdout, stderr) = glib.spawn_async( argv=["foo", "bar"], envp=None, flags=glib.SPAWN_SEARCH_PATH + glib.SPAWN_CHILD_INHERITS_STDIN, standard_input=True, standard_output=True, standard_error=True) Fails with this error: TypeError: glib.spawn_async: first argument must be a sequence of strings I tried with a tuple, which gives nothing better. What is a sequence of strings if not a list? I though about a possible Python

How to upgrade gtk2hsC2hs?

久未见 提交于 2019-12-05 11:16:44
问题 I am trying cabal install glib-0.12.3 under my Ubuntu 11.10 using cabal-install 0.10.2. However, it shows the following error messages: setup: The program gtk2hsC2hs version >=0.13.5 is required but the version found at /usr/bin/gtk2hsC2hs is version 0.13.4 cabal: Error: some packages failed to install: glib-0.12.3 failed during the configure step. The exception was: ExitFailure 1 After half an hour's search, I cannot find where this gtk2hsC2hs is. I dug into places like http://code.haskell

How can I find the length of a given GArray?

假装没事ソ 提交于 2019-12-05 08:04:30
I have a GArray of GValue (all non-zero) which has been allocated at runtime with g_array_append_val. I wonder how can I find out what's the index of the last element, or more precisely how many elements does the array hold. Code like for (length=0;g_value_get_int(&g_array_index(array, GValue, length)); length++); return length would fail with an out of bounds. It doesn't seem to be well-documented, but the number of the elements in the array is stored in the field array->len . 来源: https://stackoverflow.com/questions/33836247/how-can-i-find-the-length-of-a-given-garray

glib.h and gtk.h not found

房东的猫 提交于 2019-12-05 04:32:28
问题 hi every one i have a program in which i have include gtk/gtk.h glib.h i have used commands sudo apt-get install libgtk2.0-dev glib sudo apt-get install glade but still getting error that glib not found ans gtk/gtk.h not found. i am first time using this gtk . no idea how it works how to install it kindly help me thanks i am doing c programming 回答1: The command you're supposed to use (in more recent releases of linux/gtk) is pkg-config, not gtk-config. gtk-config is intended for pre 2.0 gtk

detect/remove unpaired surrogate character in Python 2 + GTK

↘锁芯ラ 提交于 2019-12-05 04:25:28
In Python 2.7 I can successfully convert the Unicode string "abc\udc34xyz" to UTF-8 (result is "abc\xed\xb0\xb4xyz" ). But when I pass the UTF-8 string to eg. pango_parse_markup() or g_convert_with_fallback() , I get errors like "Invalid byte sequence in conversion input". Apparently the GTK/Pango functions detect the "unpaired surrogate" in the string and (correctly?) reject it. Python 3 doesn't even allow conversion of the Unicode string to UTF-8 (error: "'utf-8' codec can't encode character '\udc34' in position 3: surrogates not allowed"), but I can run "abc\udc34xyz".encode("utf8",

Is glib usable in an unobtrusive way?

女生的网名这么多〃 提交于 2019-12-05 03:35:54
I was looking for a good general-purpose library for C on top of the standard C library, and have seen several suggestions to use glib . How 'obtrusive' is it in your code? To explain what I mean by obtrusiveness, the first thing I noticed in the reference manual is the basic types section , thinking to myself, "what, am I going to start using gint , gchar , and gprefixing geverything gin gmy gcode gnow?" More generally, can you use it only locally without other functions or files in your code having to be aware of its use? Does it force certain assumptions on your code, or constraints on your

Shell学习成果之一键自动安装PHP7.3

瘦欲@ 提交于 2019-12-05 02:33:14
系统:CentOS7.7.1908 PHP: *********************************************************************START**************************************************************************** #!/bin/bash #auto install php #by 网络虾米哥 2019-11-20 yum -y install gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers