public
Created

  • Download Gist
test.c
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#include <stdlib.h>
#include <stdio.h>
#include <yaml.h>
 
static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
{
if(!yaml_emitter_emit(emitter, event)) {
printf("oh noes\n");
exit(1);
}
}
 
int main(int argc, char *argv[]) {
yaml_event_t event;
yaml_emitter_t emitter;
 
yaml_emitter_initialize(&emitter);
yaml_emitter_set_output_file(&emitter, stdout);
 
yaml_stream_start_event_initialize(&event, YAML_UTF8_ENCODING);
emit(&emitter, &event);
 
yaml_document_start_event_initialize(&event, NULL, NULL, NULL, 0);
emit(&emitter, &event);
 
yaml_scalar_event_initialize(&event, NULL, NULL, "日本語", 9, 1, 0, 1);
emit(&emitter, &event);
 
yaml_document_end_event_initialize(&event, 0);
emit(&emitter, &event);
 
yaml_stream_end_event_initialize(&event);
emit(&emitter, &event);
 
yaml_emitter_delete(&emitter);
return 0;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.