Re: find double byte characters in a single byte string
- From: Dennis <Dennis@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Oct 2008 10:55:07 -0700
Dang! I've been chasing the wrong problem haven't I. The Mid statement is
putting the zero where I want it, the Print # is pushing it off the record
when it writes it.
"mark.tunnard.jackson@xxxxxxxxxxxxxx" wrote:
On 24 Oct, 17:17, Dennis <Den...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:.
OK, let me try to explain this better.
I am building a fixed length record, 168 bytes long, to send to a mainframe.
Once the record is built using the Mid statements in the example, it is
written to disk, with this statement:
Print #fnumCTF, TC50
The disk file is converted ASCII to EBCDIC and FTP'ed to the mainframe.
The mainframe program that processes the file expects a 168 byte record with
a zero in the last byte. If the zero is missing the mainframe program
considers the record to be invalid.
Because of the double byte characters in the timestamp, the zero that should
be in position 168 is not there, position 168 is a space.
I can't personally test the solution on a double byte operating system for a
whole lot of reasons not relevant here, so I am trying to get the solution
right before I send it to the folks having the problem and ask them to test
the solution.
I've looked at the FileDateTime function but looks like I am stuck with it
using the locale settings of the system, so the Japanese, Chinese, and Korean
(and others) will get a double byte AM/PM returned.
You have given me some suggestions that I'll try today or this weekend,
Thanks.
"Dennis" wrote:
I'm creating a string of data using this code. The data in the variable
"line" contains
a single byte string of data and also the value of FileDateTime, which may
contain the value 'AM' or 'PM' in double byte. If its double byte, the
statement that puts a zero in position 168 actually puts the 0 in position
170.
The resulting string that I need must be 168 characters long with a zero in
position 168. How can I make sure the zero is in 168?
TC50 = String(168, " ")
Mid$(TC50, 1, 10) = "9999999999"
Mid$(TC50, 11, 6) = "999999"
Mid$(TC50, 17, 6) = " //P "
Mid$(TC50, 23, Len(line)) = line
Mid$(TC50, 168, 1) = "0"
Hi
As others have mentioned it's important to realise that all VB6
strings are Unicode internally, and have two bytes per character not
one.
It sounds as though at least some of your users are running with
Japanese, Chinese or Korean regional settings? If that's the case, I
think your problem is with the Print # statement. This won't write
ASCII on those machines, it will convert the VB string to an ANSI
string and rite that. If all the characters in your string are less
than ASCII 128, the output will be indistinguishable from an ASCII
file - one byte per character. But if there are any characters above
this (e.g. Chinese, Japanese) you will be in trouble - these will be
written with more than one byte per character.
FileDateTime returns a Date, not a string, so you can cast it to a
string any way you like. If you just implicitly cast it to a string,
you will get Chinese, Japanese, etc, so it's best to avoid that.
Hope this helps
Mark
- References:
- find double byte characters in a single byte string
- From: Dennis
- RE: find double byte characters in a single byte string
- From: Dennis
- Re: find double byte characters in a single byte string
- From: mark . tunnard . jackson
- find double byte characters in a single byte string
- Prev by Date: Re: Hi
- Next by Date: Re: Active Directory - Members
- Previous by thread: Re: find double byte characters in a single byte string
- Next by thread: Disk Management
- Index(es):
Relevant Pages
|