Hi guys,
I'm writing a piece of software for some Thai friend. At the end it
is supposed to print on paper some report with tables of text and
numbers. When I test it in English, the columns are aligned nicely,
but when he tests it with Thai data, the columns are all crooked.
The problem here is that in the Thai writing system some times two or
more characters together might take one single space, for example งิ
(u"\u0E07\u0E34"). This is why when I use something like u"%10s"
% ..., it just doesn't work as expected.
Is anybody aware of an alternative string format function that can
deal with this kind of writing properly?
Any suggestion is highly appreciated. Thanks!
Andy 4 1033
En Wed, 27 Jun 2007 04:20:52 -0300, Andy <fu******@gmail.comescribió:
I'm writing a piece of software for some Thai friend. At the end it
is supposed to print on paper some report with tables of text and
numbers. When I test it in English, the columns are aligned nicely,
but when he tests it with Thai data, the columns are all crooked.
The problem here is that in the Thai writing system some times two or
more characters together might take one single space, for example งิ
(u"\u0E07\u0E34"). This is why when I use something like u"%10s"
% ..., it just doesn't work as expected.
Is anybody aware of an alternative string format function that can
deal with this kind of writing properly?
The same thing happens even in English if you print using a proportional
width font, a "W" is usually wider than an "i" or "l" letter.
You could use a reporting library or program (like ReportLab, generating
PDF files), but perhaps the simplest approach is to generate an HTML page
containing a table, and display and print it using your favorite browser.
--
Gabriel Genellina
On Jun 27, 12:20Â*am, Andy <fukaz...@gmail.comwrote:
Hi guys,
I'm writing a piece of software for some Thai friend. Â*At the end it
is supposed to print on paper some report with tables of text and
numbers. Â*When I test it in English, the columns are aligned nicely,
but when he tests it with Thai data, the columns are all crooked.
The problem here is that in the Thai writing system some times two or
more characters together might take one single space, for example งิ
(u"\u0E07\u0E34"). Â*This is why when I use something like u"%10s"
% ..., it just doesn't work as expected.
Is anybody aware of an alternative string format function that can
deal with this kind of writing properly?
In general case it's impossible to write such a function for many
unicode characters without feedback from rendering library.
Assuming you use *fixed* font for English and Thai the following
function will return how many columns your text will use:
from unicodedata import category
def columns(self, s):
return sum(1 for c in s if category(c) != 'Mn')
-- Leo
On Jun 27, 3:10Â*am, Leo Kislov <Leo.Kis...@gmail.comwrote:
On Jun 27, 12:20Â*am, Andy <fukaz...@gmail.comwrote:
Hi guys,
I'm writing a piece of software for some Thai friend. Â*At the end it
is supposed to print on paper some report with tables of text and
numbers. Â*When I test it in English, the columns are aligned nicely,
but when he tests it with Thai data, the columns are all crooked.
The problem here is that in the Thai writing system some times two or
more characters together might take one single space, for example งิ
(u"\u0E07\u0E34"). Â*This is why when I use something like u"%10s"
% ..., it just doesn't work as expected.
Is anybody aware of an alternative string format function that can
deal with this kind of writing properly?
In general case it's impossible to write such a function for many
unicode characters without feedback from rendering library.
Assuming you use *fixed* font for English and Thai the following
function will return how many columns your text will use:
from unicodedata import category
def columns(self, s):
Â* Â* return sum(1 for c in s if category(c) != 'Mn')
That should of course be written as def columns(s). Need to learn to
proofread before posting :)
-- Leo
Thanks guys!
I've used the HTML and the unicodedata suggestions, each on a
different report. These worked nicely!
Andy This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Matt Garman |
last post by:
I've got some code that generates a report for the user. The report is
shown with explanatory verbage. The text is relatively long, and also
has some simple formatting (paragraphs, bulleted...
|
by: Dennis Myrén |
last post by:
Hi.
Is there a way to utilize the great primitive data type
formatting routines available in .NET without working with
strings?
I want a byte directly rather than a string.
I think it is...
|
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if...
|
by: Oenone |
last post by:
Is it possible to create an object which can have methods and properties,
but which can also be treated as a string?
I'm trying to create a wrapper around the IIS Request.Form object which...
|
by: Modica82 |
last post by:
Hi All,
I am very new to web services, so am struggling to understand exactly what I
am doing with regards to its returns etc. I have been given the task of
designing and developing a web...
| |
by: L. Scott M. |
last post by:
Have a quick simple question:
dim x as string
x = "1234567890"
-------------------------------------------------------
VB 6
dim y as string
|
by: Jiho Han |
last post by:
Here's the issue.
You have a class,
Class Person
{
public int id;
public string firstname;
public string lastname;
}
|
by: schoedl |
last post by:
Hello,
we often compose strings via a ostringstream and then create a string
from it. What is the rationale of not being able to use string in
place of a ostringstream, so I could write
...
|
by: coomberjones |
last post by:
I have a few std::strings that I am using to store raw binary data,
each of which may very well include null bytes at any point or
points. I want to slap them together into a single string, so I...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |