Index: src/OFMutableString.h ================================================================== --- src/OFMutableString.h +++ src/OFMutableString.h @@ -85,21 +85,21 @@ /*! * @brief Appends a formatted string to the OFMutableString. * * See printf for the format syntax. As an addition, %@ is available as format - * specifier for objects. + * specifier for objects and %C for of_unichar_t. * * @param format A format string which generates the string to append */ - (void)appendFormat: (OFConstantString*)format, ...; /*! * @brief Appends a formatted string to the OFMutableString. * * See printf for the format syntax. As an addition, %@ is available as format - * specifier for objects. + * specifier for objects and %C for of_unichar_t. * * @param format A format string which generates the string to append * @param arguments The arguments used in the format string */ - (void)appendFormat: (OFConstantString*)format Index: src/OFStream.h ================================================================== --- src/OFStream.h +++ src/OFStream.h @@ -985,11 +985,11 @@ /*! * @brief Writes a formatted string into the stream. * * See printf for the format syntax. As an addition, %@ is available as format - * specifier for objects. + * specifier for objects and %C for of_unichar_t. * * @param format A string used as format * @return The number of bytes written */ - (size_t)writeFormat: (OFConstantString*)format, ...; @@ -996,11 +996,11 @@ /*! * @brief Writes a formatted string into the stream. * * See printf for the format syntax. As an addition, %@ is available as format - * specifier for objects. + * specifier for objects and %C for of_unichar_t. * * @param format A string used as format * @param arguments The arguments used in the format string * @return The number of bytes written */ Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -263,11 +263,11 @@ /*! * @brief Creates a new OFString from a format string. * * See printf for the format syntax. As an addition, %@ is available as format - * specifier for objects. + * specifier for objects and %C for of_unichar_t. * * @param format A string used as format to initialize the OFString * @return A new autoreleased OFString */ + (instancetype)stringWithFormat: (OFConstantString*)format, ...; @@ -492,11 +492,11 @@ /*! * @brief Initializes an already allocated OFString with a format string. * * See printf for the format syntax. As an addition, %@ is available as format - * specifier for objects. + * specifier for objects and %C for of_unichar_t. * * @param format A string used as format to initialize the OFString * @return An initialized OFString */ - initWithFormat: (OFConstantString*)format, ...; @@ -503,11 +503,11 @@ /*! * @brief Initializes an already allocated OFString with a format string. * * See printf for the format syntax. As an addition, %@ is available as format - * specifier for objects. + * specifier for objects and %C for of_unichar_t. * * @param format A string used as format to initialize the OFString * @param arguments The arguments used in the format string * @return An initialized OFString */ Index: src/of_asprintf.m ================================================================== --- src/of_asprintf.m +++ src/of_asprintf.m @@ -26,10 +26,12 @@ #include #import "OFString.h" +#import "OFInvalidEncodingException.h" + #import "asprintf.h" #import "autorelease.h" #import "macros.h" #define MAX_SUBFORMAT_LEN 64 @@ -310,10 +312,26 @@ "(nil)"); } @catch (id e) { free(ctx->buffer); @throw e; } + + break; + case 'C': + ctx->subformat[ctx->subformatLen - 1] = 's'; + + { + char buffer[5]; + size_t len = of_string_utf8_encode( + va_arg(ctx->arguments, of_unichar_t), buffer); + + if (len == 0) + @throw [OFInvalidEncodingException exception]; + + buffer[len] = 0; + tmpLen = asprintf(&tmp, ctx->subformat, buffer); + } break; case 'd': case 'i': switch (ctx->lengthModifier) { Index: utils/OFZIP.m ================================================================== --- utils/OFZIP.m +++ utils/OFZIP.m @@ -92,11 +92,11 @@ break; case 'h': help(of_stdout, true, 0); break; default: - [of_stderr writeFormat: @"%@: Unknown option: -%c\n", + [of_stderr writeFormat: @"%@: Unknown option: -%C\n", [OFApplication programName], [optionsParser lastOption]]; [OFApplication terminateWithStatus: 1]; } }