Ticket #18542: App.cpp

File App.cpp, 863 bytes (added by humdinger, 9 months ago)
Line 
1#include <Locale.h>
2#include <NumberFormat.h>
3#include <String.h>
4#include <StringForSize.h>
5#include <StringFormat.h>
6
7#include <stdio.h>
8
9
10#undef B_TRANSLATION_CONTEXT
11#define B_TRANSLATION_CONTEXT "App"
12
13
14int
15main()
16{
17 BLocale locale;
18 BNumberFormat format(&locale);
19 BString decimal(format.GetSeparator(B_DECIMAL_SEPARATOR));
20 BString grouping(format.GetSeparator(B_GROUPING_SEPARATOR));
21 printf("BNumberFormat separators: decimal: %s\t1000: %s\n\n", decimal.String(), grouping.String());
22
23
24 size_t value = 1024;
25 char sizeBuffer[128];
26 BString buffer = string_for_size(value, sizeBuffer, sizeof(sizeBuffer));
27 printf("string_for_size: %s\n", buffer.String());
28
29
30 BString result;
31 static BStringFormat sizeFormat("{0, plural, one{(# byte)} other{(# bytes)}}");
32 sizeFormat.Format(result, value);
33 printf("BStringFormat: %s\n", result.String());
34
35 return 0;
36}