Git Product home page Git Product logo

Comments (2)

RandyGaul avatar RandyGaul commented on May 3, 2024

They take a length parameter, is in length of the input buffer or length of the output buffer. They are dead simple wrappers over decode/encode, as in they don't really do anything smart. I'm guessing you passed in input buffer length into the first function and second function, but I wrote the second function that takes an output buffer length and no input length. For the shorten/widen functions, the lengths are associated with the buffers that are in utf8 format, which is confusing and not a great choice... I was probably just focusing really hard on the utf8 part when I wrote them.

Feel free to make your own wrapper function that does specifically what you need :)

Here's an example that works without buffer lengths (didn't test the code, but hopefully it works the way you expected):

void Widen(const char* in, whcar_t* out)
{
	int cp;
	while (*in)
	{
		in = tuDecode8(in, &cp);
		out = tuEncode16(out, cp);
	}
}

After thinking about it, the best approach would probably be to have the header come with a few different kinds of widening functions for people that are dealing with different string formats. Some people just like passing pointers around, and other people like passing pointer + buffer lengths. Maybe like these ones would be good:

void Widen(const char* in, whcar_t* out);
void Widen(const char* in, int in_len, whcar_t* out);
void Widen(const char* in, int in_len, whcar_t* out, int out_len);
void Widen(const char* in, whcar_t* out, int out_len);

from cute_headers.

RandyGaul avatar RandyGaul commented on May 3, 2024

OK I'll make these functions and push them out. Thanks for asking @ddengster ! Closing for now, comment away if you wanted to chat more.

from cute_headers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.