Skip to content

Instantly share code, notes, and snippets.

@tbeu
tbeu / unicode.c
Created March 14, 2021 20:38 — forked from tommai78101/unicode.c
UTF-8 to UTF-16 one-way conversion, written in C
#include <stdio.h>
#include <stdlib.h>
#include <uchar.h>
#include <locale.h>
#define __STD_UTF_16__
//Pointer arrays must always include the array size, because pointers do not know about the size of the supposed array size.
void utf8_to_utf16(unsigned char* const utf8_str, int utf8_str_size, char16_t* utf16_str_output, int utf16_str_output_size) {
//First, grab the first byte of the UTF-8 string
#include "mat.h" // from MATLAB
#include "matrix.h" // from MATLAB
#include "matio.h" // https://github.com/tbeu/matio
#include "string.h"
#include "stdlib.h"
/*
* Open a MAT-file "filename" using mode "mode". Return
* a pointer to a MATFile for use with other MAT API functions.
@tbeu
tbeu / Streams.mo
Last active January 13, 2016 17:13
New functions for Modelica.Utilities.Streams
function readMatrixSize "Read dimensions of a 2D Real array from file"
extends Modelica.Icons.Function;
input String fileName "File where external data is stored" annotation(Dialog(loadSelector(filter="MATLAB MAT-files (*.mat)", caption="Open MATLAB MAT-file")));
input String matrixName "Name / identifier of the 2D Real array on the file";
output Integer dim[2] "Number of rows and columns of the 2D Real array";
external "C" ModelicaIO_readMatrixSizes(fileName, matrixName, dim) annotation(Library={"ModelicaIO", "ModelicaMatIO", "zlib"});
annotation(Documentation(info="<html><p>Read the 2D dimensions from a binary MATLAB MAT-file.</p></html>"));
end readMatrixSize;
function readRealMatrix "Read 2D Real values from file"
From e19c423f133518498582236fc6bd55cf6112ed79 Mon Sep 17 00:00:00 2001
From: tbeu <tbeu@users.noreply.github.com>
Date: Mon, 27 Apr 2015 09:42:58 +0200
Subject: [PATCH] Fix execution order
---
Modelica_DeviceDrivers/Blocks/Communication.mo | 23 +++++++++++++++++++---
.../Blocks/Examples/TestSerialPackager_UDP.mo | 10 ++++++++--
2 files changed, 28 insertions(+), 5 deletions(-)