Subject: | |
From: | |
Reply To: | |
Date: | Wed, 20 May 2015 09:02:50 +0100 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Hi,
This is probably me but I am struggling a bit on how to deal with the output of a search in c#. e.g. a simple isbn search.
string mrc = query.Z3950Search("9781119010173", 7);
Our library z3950 is UTF-8. But if I write this mrc to a file or just write to console the record is invalid. In order for this to be a valid record I need to change the encoding of the string from the default to UTF-8. After a bit of googling I got
byte[] bytes = Encoding.Default.GetBytes(mrc);
mrc = Encoding.UTF8.GetString(bytes);
This string writes to file nicely and looks right in the console. Everything would be fine except our Bibliographic data supplier uses MARC8 and for this, the mrc string seems to write to console OK, but when writing to file I get an invalid record with some unexpected characters again. Is there a similar way to encode this string so it produces a valid record?
The MARCEngine5.MARC21.MARC2stream method appears to do the right thing regardless of the encoding of the z39 target. However I would like to work out how to save the raw marc correctly
Sample code below
--snip--
public static void Main()
{
string path = "c:\\utils\\scripts\\files\\";
string found = path + "found.mrc";
Query query = new Query();
query.Start = 0;
query.Limit = 1;
query.Host = "library.bury.gov.uk";
query.Database = "INNOPAC";
query.Port = 210;
query.Syntax = "USMARC";
string mrc = query.Z3950Search("9781119010173", 7);
using (StreamWriter writer = new StreamWriter(found)) {
writer.Write(mrc);
}
Console.WriteLine(mrc);
MARC21 rec = new MARC21();
string mn = rec.MARC2Stream(mrc);
Console.WriteLine(mn);
mrc = rec.Mnemonic2Stream(mn);
Console.WriteLine(mrc);
//byte[] bytes = Encoding.Default.GetBytes(mrc);
//mrc = Encoding.UTF8.GetString(bytes);
}
-----------------------------------------------------------------
Why not visit our website www.bury.gov.uk
-----------------------------------------------------------------
Incoming and outgoing e-mail messages are routinely monitored for compliance
with our information security policy.
The information contained in this e-mail and any files transmitted
with it is for the intended recipient(s) alone. It may contain
confidential information that is exempt from the disclosure under
English law and may also be covered by legal,professional or other privilege.
If you are not the intended recipient, you must not copy, distribute or take any
action in reliance on it.
If you have received this e-mail in error, please notify us immediately by using
the reply facility on your e-mail system.
If this message is being transmitted over the Internet, be aware that it may be
intercepted by third parties.
As a public body, the Council may be required to disclose this e-mail or any
response to it under the Freedom of Information Act 2000 unless the information
in it is covered by one of the exemptions in the Act.
Electronic service accepted only at [log in to unmask] and on fax number
0161 253 5119 .
*************************************************************
________________________________________________________________________
This message comes to you via MARCEDIT-L, a Listserv(R) list for technical and instructional support in MarcEdit. If you wish to communicate directly with the list owners, write to [log in to unmask] To unsubscribe, send a message "SIGNOFF MARCEDIT-L" to [log in to unmask]
|
|
|