Thursday, June 19, 2008

Code 128 font (barcode) code in C#

I have problem using code128 barcode font.
When I use character 154 (& #154) in html it will be š but in C# its wrong.
š value will be 353 in C#.
So I make table for the character.
here's the codes:



readonly static string code128AsciiTable = "€!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~‘’“”•–—˜™š›œ";
private char Code128ToAscii(char c)
{
char res = (char)code128AsciiTable[(int)c];
return res;
}
private char AsciiToCode128(char c)
{
char res = (char)code128AsciiTable.IndexOf(c);
return res;
}
private char Code128CheckSum( string str, char startChar )
{
int result = 0;
for (int i = 0; i < str.Length; ++i)
{
result += (int)str[i] * (i + 1);
}
result += (int)startChar;
result %= 103;
result = Code128ToAscii((char)result);
return (char)result;
}
public string ConvertToCode128Format(string str)
{
char startChar = code128AsciiTable[104];
char stopChar = code128AsciiTable[106];
string convertedStr = "";
for (int i = 0; i < str.Length; ++i)
{
convertedStr += AsciiToCode128(str[i]);
}
char checkSum = Code128CheckSum(convertedStr, (char)104);
string FullConvert = startChar + str + checkSum + stopChar;
return FullConvert;
}
public void Test()
{
string testString = "156461003";
string code128String = ConvertToCode128Format(testString);
}


Friday, June 13, 2008

Agile Planning in my office

For the past 7 months, I've been introduced and experiencing a whole new world of software development planning, that's called Agile Planning. Well, I know it's not a new thing, but it is for me. I heard a lot about this method since 2 years ago, but I haven't got a chance to experienced it until 7 months ago.
When I first heard about it, I thought it was just another gimmick in software development, that will be forgotten in 2-3 years. But I was wrong, and I'm glad I'm wrong, because --for me-- this method is the best system in software development planning.
It so simple, but yet it so spot on in solving the problems in old ways of planning (waterfall). Starting from the scrum meeting, sprint, and milestone. It just feel so right for me.
I recommend everybody working in software business, at least have a try implementing agile development. Read Mike Kohn's books, or at least check his website.