How can I shorten the strings? - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23

Thread: How can I shorten the strings?

  1. #16
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    UuidCreate(...)
    UuidFromString(...)
    UuidToString(...)

    check msdn msdn.microsoft.com

  2. #17
    Join Date
    Mar 2003
    Location
    Chongqing,China
    Posts
    59
    Thank Marc from D. I will think about your idea. And if I still have any questions, I will bother you again.

    And thank Mick too.Maybe your answer gives me a great help.
    Stone

  3. #18
    Join Date
    Jan 2004
    Location
    Earth
    Posts
    567
    Hi,

    You could do some type of algorithm on the original string. Maybe something simple like split the string in half and then add the 2 segments together. Maybe something more involved like split the string in half and get something like a a CRC value from the 2 halves that is 24 digits.

    CRC information

    TDM
    Last edited by TDM; March 6th, 2004 at 03:39 PM.

  4. #19
    Join Date
    Mar 2003
    Location
    Chongqing,China
    Posts
    59
    Hi,TDM.I would think about your idea too.
    Thanks a lot.
    Stone

  5. #20
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,221
    Just a small modification to TDM's idea...

    Even if you split the string into two halves, each half would still be too big to handle, even using 64-bit maths. You'd need to write something to handle at least 96-bit calculations to avoid losing accuracy.

    A small modifcation would be to split the 47 character string into 3, which would allow you to use 64-bit arithmetic. You could then use TDM's suggestion to generate a CRC value for each part.
    "A problem well stated is a problem half solved. - Charles F. Kettering

  6. #21
    Join Date
    Mar 2003
    Location
    Chongqing,China
    Posts
    59
    Is the CRC value exclusive?
    Stone

  7. #22
    Join Date
    May 2002
    Location
    Germany
    Posts
    487
    As long as you shorten your string in a mathematical way you will loose data and so uniqueness. As the CRC is much shorter than the original string, it is possible to have several strings that will produce the same CRC.
    CRC is typically used to verify that a string has not been changed. So each String has a fix CRC. But a CRC will fit to several strings.
    It is IMHO not useful to create just unique numbers.

    Situation changes as long as you strip down the redundant data. To do this you have to think about the content of the string. Maybe you have always "0" at multiple, defined positions? In this case you can just cut them out.

    ... but this is what I stated in an earlier posting.

    Marc

  8. #23
    Join Date
    Jun 2004
    Posts
    1
    Hi
    Originally posted by stoneyrh
    I am so sorry for my poor expression.
    The question should be,
    I combine a CpuID-string and the current date-time string as a long string to identify one special user in my database.But the CpuID-string has 32 characters and the current date-time string has 15 characters.So the result string has 47 characters.
    It is too long for my application,because I hope the string can be used as a barcode,and the barcode will be printed to a card which is kept by the user.The long barcode is too long to be read by the barcode-reader.So I want to shorten the string.

    One example of the string is:
    3febf9ff00000f0a007a704000000000200402071122367

    Thanks a lot.
    Use EACH PAIR of characters as an ascii character.

    For example


    3f = ascii char ?
    eb = ascii char
    f9 = ascii char

    The characters printed will vary a little depending on the character set used when printing the barcode. However I "think" that if you use code 39 (can print characters) the appropriate code value ie the number from which you create the string, should be the same immaterial of what the printed text looks like.

    What this means is that in different languages or codepages in the pc, the visible text may look diferent but the NUMBER should be the read by the scanner as the same numeric value. Obviously you would have to decode this "encoded" number to obtain the numeric value.

    There are only two problems that I can see, the code used MUST BE numeric ONLY (decimal or hex) and you cannot use both the FF value AND the 32 value. As both are likely to be PRINTED as a space character (FF is a "hard" space character).

    Well I hope this helps somehow. At least it has the potential to reduce your string by half.

    Please let me know how you get on and if this does help you.

    Regards

    Peter

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center