Char Array to String in VB.NET 2.0

Written by Zealus on April 22, 2009 – 3:29 pm -

You will be surprised, but the obvious

Dim arrChars(10) As Char
Dim strString As String
strString = "ABCDEFGHIK"
arrChars = strString.ToCharArray
strString = arrChars.ToString

Will not yield the same string as there was before. It will, rather, return “Char[]” response. To get your string back from Char Array (at least in VB.NET 2.0) you will need to call CStr on array:

Dim arrChars(10) As Char
Dim strString As String
strString = "ABCDEFGHIK"
arrChars = strString.ToCharArray
strString = Cstr(arrChars)

Funny, isn’t it? And totally counter-intuitive :)


Tags: , , ,
Posted in annoyances, programming | 2 Comments »

Useful Language-Changing JavaScript

Written by Zealus on September 13, 2008 – 9:41 am -

Recently I had to quickly make a copy of the same web site iin a different language. Instead of coming up with complicated solutions (the web site isn’t that big and the second language was long overdue) I decided to copy the contents into a subdirectory and just substitute the contents in English with the same in Spanish.

The thought behind was that I can alternate between each page using simple javascript routine. So there I have example.com in English, example.com/sp/ same thing in Spanish. Same pages are named the same, so it’s example.com/about_us.html and example.com/sp/about_us.html – otherwise the script it useless.

The function is fairly simple:

function langChange() {
var pt = location.pathname;
var hs = location.host;

if (pt.length < 4) {
newloc = ‘http://’ + hs + ‘/sp/’;
} else {
if (pt.substring(0, 4) == ‘/sp/’) {
newloc = ‘http://’ + hs + ‘/’ + pt.substring(4);
} else {
newloc = ‘http://’ + hs + ‘/sp’ + pt;
}
}
window.location.assign(newloc);
}

Pretty universal, works everywhere. Set in as an onclick() event for your language changing butn and you’re good to go.

P.S. If you have much faith in Javascript – feel free to add ajax call to database for current page to figure out the counterpart in a different language.


Tags: , ,
Posted in programming | Comments Off

Security threats

Written by Zealus on May 4, 2006 – 12:30 am -

Somebody out there doesn’t really like Invision PowerBoard… today I saw fifth (yeah, that’s number 5) vulnerability patch for single release 2.1.5

People on IPS forums are screaming…


Tags: , ,
Posted in programming, technology, web | Comments Off